androidcordovanativephonegap-pluginswebintents

PhoneGap - Call another application (AngryBirds)


I'm implementing phonegap based application for android and want to call angry birds game from inside the phonegap app. After my quick research here and here I have following:

/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>

main.js

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

I'm stuck here and have_no_idea what should be written for url:. Any help? Or there is another way to call for other application from phonegap?


Solution

  • This java code should work

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

    or try any of this 2 plugins for opening apps

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

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