开发者

Launching Android app, within an app?

开发者 https://www.devze.com 2023-01-22 19:12 出处:网络
I\'m writing a basic application.One of the features I\'m interested in trying to do is to launch another app, INSIDE the app already running.

I'm writing a basic application. One of the features I'm interested in trying to do is to launch another app, INSIDE the app already running.

Eg. I have an app with 3 menu options, 1 and 2 do 开发者_StackOverflow中文版certain tasks as part of this parent app, menu option 3 launches another app that's installed on the phone. I'm not sure if this is possible?


This is possible with the Intents mechanism.

The exact Intent you'll have to write depend on various factors:

  • do you have to provide some data to the launched application?
  • do you target a specific application or do you want to let the user choose the application he prefers for that task (in case he has several applications able to do what you need)?
  • do you want to ensure that the application is available? (that would be better)
  • do you know if the other app provides specific intent-filters to do some tasks?

Edit:

Then, you should be able to start the second application with the following code:

Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setPackage("com.otherapp.package");
startActivity(i);

Place this code in the OnClickListener of your button and that should be enough.

0

精彩评论

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

关注公众号