Launch native apps from custom cordova app

半城伤御伤魂 提交于 2019-12-10 10:34:45

问题


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.



来源:https://stackoverflow.com/questions/36362096/launch-native-apps-from-custom-cordova-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!