Tuesday, January 3, 2012

How to Disable Back button in android


/**
* To disable back button(when click back button nothing happen)
*/
@Override
public void onBackPressed() {
  return;
}

How to Launch Activities from different application in android



For Example We have two application with same package and Different Namespace.
First Application: Com.Example.Application1
Second Application: Com.Example.Application2
In this case you can define common Manifest file for both Application1 and Application2 as given below
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="Com.Example">
And add given line to your manifest file
<activity android:name=".Application2/Activity2">
  <intent-filter>
    <action android:name="Application2.intent.action.Launch" />
    <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</activity>
Now you can create an Intent to launch Activity2 from the Activity1 with this line of code:
Intent intent = new Intent("Application2.intent.action.Launch");
startActivity(intent);