Tag Archives: Y Quot

All about ArrayList – Android.

By | October 12, 2012

[java] package com.coderzheaven.arraylistcomplete; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Vector; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @SuppressWarnings("unchecked") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ArrayList<String> al = new ArrayList<String>(); System.out.println("Initial size of al: " + al.size()); al.add("C"); al.add("A"); al.add("E"); al.add("B"); al.add("D"); al.add("F"); al.add(1, "A2"); System.out.println("Size of al after… Read More »

How to use Accelerometer in Android?

By | May 30, 2012

This is a simple post showing how to use accelerometer in android. This java code prints the values of x,y and z axis in the console. [java] package com.coderzheaven.pack; import android.app.Activity; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; public class AccelerometerTest extends Activity implements SensorEventListener{ private SensorManager sensorManager; double ax,ay,az; // these are the acceleration… Read More »

How to get touch location in Corona ?

By | August 21, 2011

Hi, For getting touch location in Corona, use the following code, [c] –Your touch event listener local function myTouchListener( event ) if event.phase == "began" then –Touch coordinates can be accessed by event.x/event.y properties of touch event print( "Touched!" ) print ("Touch X = #"..event.x) print ("Touch Y = #"..event.y) end end –Adding an event listener for touch… Read More »

How will you access the clipboard in an AIR application?

By | January 15, 2011

The following is a sample code to do this. Simply copy and paste. [xml] <xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> public function init():void{ var str : String = "Hello"; System.setClipboard(str); var versionString:String = Capabilities.version; var pattern:RegExp = /^(w*) (d*),(d*),(d*),(d*)$/; var result:Object = pattern.exec(versionString); if (result != null) { trace("input: " + result.input); trace("platform: " + result[1]); trace("majorVersion: " + result[2]); trace("minorVersion:… Read More »

How do you call an actionscript function from a html page and viceversa. How to you access the actionscript variable function from an HTML page in actionscript.

By | December 26, 2010

The following code helps you to do this. Save the following  code as am .mxml file [xml] <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ private var calledFromJSHandlerFunction:Function = calledFromJSHandler; private function init():void{ html.addEventListener(Event.HTML_DOM_INITIALIZE, domInitialized); html.location = "start.html"; } private function domInitialized(event:Event):void{ html.htmlLoader.window.calledFromJSHandlerFunction = calledFromJSHandlerFunction; } private function calledFromJSHandler():void { mx.controls.Alert.show("ActionScript called from JavaScript", "Alert"); } private… Read More »