in Android Code Tips

Let others start your android app

Supposing you have an Android application and you want others to be able to start it through their application and pass data into it, you will need to use an intent.

First you have to declare to your manifest file what intent name your activity will listen to.

	<application android:icon="@drawable/icon" android:label="@string/app_name">
		<activity android:name=".myApp" android:label="@string/app_name">
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />

				<action android:name="com.myApp.Start" />
				<category android:name="android.intent.category.DEFAULT" />

Then everyone else will be able to start your application just by calling the intent’s name

	Intent intent1 = new Intent("com.myApp.Start");

You can also pass data to the intent

	Intent intent1 = new Intent("com.myApp.Start");
	intent1.putExtra("name", "kostis");

and get them back

Intent beginningIntent = getIntent();
if (beginningIntent != null)
   String name = beginningIntent.getExtras().getString("name");

Other tips and code examples by me on android can be found here