【问题标题】:PhoneGap - Call another application (AngryBirds)PhoneGap - 调用另一个应用程序 (AngryBirds)
【发布时间】:2013-06-05 09:17:13
【问题描述】:

我正在为 Android 实现基于 phonegap 的应用程序,并希望从 phonegap 应用程序内部调用愤怒的小鸟游戏。经过对herehere 的快速研究,我得到了以下信息:

/src/com.borismus.webintent.WebIntent.java

/www/webintent.js

AndroidManifest:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="orientation">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <data android:scheme="com.rovio.angrybirds" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
</activity>

ma​​in.js

function onClickStartAngry() {
    window.plugins.webintent.startActivity({
        action: WebIntent.ACTION_VIEW,
        url: 'have_no_idea'},
        function() {};
    function() {alert('Failed to open AngryBirds App')};
});
}

我被困在这里,have_no_idea 应该为url: 写什么。有什么帮助吗?或者还有其他方法可以从 phonegap 调用其他应用程序?

【问题讨论】:

  • 你试过什么?根据对您提供的链接的快速阅读,如果您不需要将额外数据传递给意图,似乎甚至可能不需要 URL。例如,如果您启动 YouTube 应用,则 URL 将是要打开的视频……但根据您的意图,我不确定您是否需要传递这些额外信息。
  • @MBillau 我尝试使用url: https://play.google.com/store/apps/details?id=com.rovio.angrybirds 运行应用程序,但游戏没有启动。有什么建议吗?
  • 空的url 会发生什么?

标签: android cordova native phonegap-plugins webintents


【解决方案1】:

这个java代码应该可以工作

Intent LaunchIntent = this.cordova.getActivity().getPackageManager().getLaunchIntentForPackage("com.rovio.angrybirds");
this.cordova.getActivity().startActivity(LaunchIntent);

或尝试使用这 2 个插件中的任何一个来打开应用程序

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

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

【讨论】:

    猜你喜欢
    • 2014-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多