5

From my application i have to open a another one application.Is there any possibility to open like this?

RMK
  • 779
  • 3
  • 9
  • 13
  • 1
    check the use of Intents http://developer.android.com/reference/android/content/Intent.html – Noya Jul 27 '10 at 10:37

3 Answers3

7

You should use the function of the package manager.

try {
    Intent i = ctx.getPackageManager().getLaunchIntentForPackage("com.android.browser");
    ctx.startActivity(i);
} catch (NameNotFoundException e) {
    // TODO Auto-generated catch block
}
Christopher Gertz
  • 1,826
  • 1
  • 15
  • 9
  • In case getLaunchIntentForPackage returns null, please, refer to this answer: https://stackoverflow.com/a/65140578/1803222 or this tutorial: https://developer.android.com/training/package-visibility/declaring. In short, you must add to your manifest. – Anhayt Ananun Sep 24 '21 at 18:13
3

Probably you are looking for a way to start another class from another package

Intent myIntent = new Intent();
myIntent.setClassName("com.android.samples", "com.android.samples.Animation1");
myIntent.putExtra("com.android.samples.SpecialValue", "Hello, Joe!"); // key/value pair, where key needs current package prefix.
startActivity(myIntent);    

Read a tutorial post about Opening a Screen at Common Tasks post.

agf
  • 171,228
  • 44
  • 289
  • 238
Pentium10
  • 204,586
  • 122
  • 423
  • 502
1

You can launch other applications with Activity.startActivity( intent);

Use it like this:

Intent intent = new Intent();
String pkg = "com.android.browser";
String cls = "com.android.browser.BrowserActivity";
intent.setClassName(pkg, cls); 
startActivity(intent);

You need to know the package and class names of the activity to call, the Package Browser in the Dev Tools app will help here if its not your own app to call.

Peter Ajtai
  • 56,972
  • 13
  • 121
  • 140
Thorstenvv
  • 5,376
  • 1
  • 34
  • 28
  • 2
    Please note that using hand-written constants like "com.android.browser" and "com.android.browser.BrowserActivity" is using private implementation details (these are not part of the SDK), and thus you should expect such code to break across different devices and platform versions. – hackbod Jul 27 '10 at 11:19