简体   繁体   中英

How to launch a mobile app from another app?

Is there any way to launch for one mobile app to launch another mobile app, eg via a button click?

Example: the org.apache.cordova.camera plugin allows direct access to the camera on a button click. In the same way, how can one app launch another app?

You can use this java code:

Intent LaunchIntent = this.cordova.getActivity().getPackageManager().getLaunchIntentForPackage("appPackage");
this.cordova.getActivity().startActivity(LaunchIntent);

or try any of this 2 plugins for launching apps

https://github.com/lampaa/org.apache.cordova.startapp

https://github.com/dmedvinsky/cordova-startapp

Try this

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("package name here");
startActivity( LaunchIntent );

If you don't know the package name of application that you want to launch then try this

PackageManager pm;
pm = getPackageManager();
//  get a list of all installed apps then launch by pakagename.
packages = pm.getInstalledApplications(0);

String packagename = packages.get(position).packageName.toString()

Refer this android-package-manager

You need to find out full name of application, and then start it as activity via intent like this:

Intent myIntent = new Intent(getApplicationContext(), "full name of activity you are starting");
startActivity(myIntent);

You can even receive result from that activity check this . Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM