开发者

Open another one application from our application?

开发者 https://www.devze.com 2023-01-09 05:15 出处:网络
From my application i have to open a another one application.Is there 开发者_开发百科any possibility to open like this?You should use the function of the package manager.

From my application i have to open a another one application.Is there 开发者_开发百科any possibility to open like this?


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
}


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.


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

精彩评论

暂无评论...
验证码 换一张
取 消