Launch native apps from custom cordova app

2019-05-20 15:51发布

问题:

I'm developing a mobile app with Cordova (in Intel XDK) which is a list of buttons that launches other apps.

So far I've managed to launch phone app (href="tel://"), sms (href="sms://) and google website in browser (href="http://google.com").

I've found a plugin for starting apps: https://github.com/lampaa/com.lampa.startapp but basing on guide provided there I can launch an app with code like this (example) :

navigator.startApp.start([["app.com.name", "app.com.name.Activity"], [{"product_id":"100"}]], ...);

But how can I find those full app names (these app.com.name strings) ?

I need names for these apps (or way how to open them):

  • Videos (default app for android),
  • Pictures / Camera Roll (default app for android),
  • Camera,
  • WiFi settings,
  • Bluetooth settings,
  • Browser window with blank or home page opened.

Just to remind: I don't want to sync any data between these apps and mine - I just want simply to launch it via my app.

If You have other solutions - I'm open for any suggestions.

回答1:

Videos (default app for android),

Requires InAppBrowser Plugin to be installed. In your code simply call cordova.InAppBrowser.open('videos://', '_system', 'location=yes');

Pictures / Camera Roll (default app for android) & Camera

Requires Camera Plugin. navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);

Settings

Check out this Native Settings Plugin

Browser window with blank or home page opened.

Requires InAppBrowser Plugin to be installed. In your code simply call cordova.InAppBrowser.open('http://google.org', '_system', 'location=yes'); This will open the default browser installed.

Many apps have well known URL Schemes defined that you can use to open app directly with. Heres a list. Whichever app URL you're using, make sure you add it to your whitelist in config.xml. <allow-intent href="twitter:*" /> <allow-intent href="mailto:*" /> The more recent approach is to use Universal Links as apposed to the URL.