Open another one application from our application?

后端 未结 3 1610
旧巷少年郎
旧巷少年郎 2021-01-13 04:21

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

相关标签:
3条回答
  • 2021-01-13 05:08

    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.

    0 讨论(0)
  • 2021-01-13 05:08

    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.

    0 讨论(0)
  • 2021-01-13 05:13

    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
    }
    
    0 讨论(0)
提交回复
热议问题