PhoneGap - Call another application (AngryBirds) - android

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?

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

Related

Using Deep link to open app with external link

I am trying to make my android app open when the user presses on a link to our website.
I was following this documentation but it is not working for me as it always opens the browser instead of asking if I would like to continue with the browser or the app. What am I doing wrong?
here is my manifest
<activity
android:name=".presentation.MainActivity"
android:exported="true"
android:label="#string/app_name"
android:theme="#style/Theme.LegendaryCollectionsAndroid.NoActionBar"
android:allowTaskReparenting="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data
android:host="www.legendarycollections.net"
android:path="/reset"
android:scheme="https"></data>
</intent-filter>
</activity>
check your website association here.

Browser can't open an app from a browser using deeplink

I'm trying to implement deeplinks in my, so users will be able to open the application from a browser. So, I've added deeplinks in my application in a Manifest.xml. And this code is working from adb, but when I'm trying to open this link in browser, the application does not opens. What can cause this error? I can even can't see an Intent in my code
<activity
android:name=".ui.main.MainActivity"
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http"
android:host="example.com"
android:pathPrefix="/"/>
</intent-filter>
</activity>
Use Firebase deep link ( Hope Help-full )
https://firebase.google.com/docs/dynamic-links

How to avoid multiple open in particular application in android?

I have already opened my android application. I used url scheme, so that my app can be opened from the users email. But if i try to open my application from clicking email link from the web browser, it will open that application in separate window. (Please see my attached screen short picture) .
How to avoid my application to open twice separately?
<activity
android:name="com.mYs3.MainActivity.flash_screen"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="mYs3" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
try this line in your activity block in manifest
android:launchMode="singleTask"

Could not launch application by calling a URL from Android Browser

There are many answers in stackoverflow showing how to lauch app from a web browser ,but I am not sure what went wrong with my code, that never seems to be doing the intended.
I am trying to launch my app by a URL from any other app like web browser,initially
my manifest file looks like this
<activity android:name=".Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="http" android:host="ebay.com" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
And When I typed http://ebay.com in the browser that never started my app.Obviously,how does the browser know about my app?,then i tried the other way around and added another Activity called MyActivity and altered the manifest file as
<activity android:name=".Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MyActivity">
<intent-filter>
<data android:scheme="http" android:host="ebay.com" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
and tried in my Main Activity
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://mycityway.com")));
Thus producing the intended result.I can also start another application Activity using this method.
But most of the answers here says that the later is possible.What is the mistake i am doing,I couldn't launch my app from browser.Please guide me.
And When I typed http://ebay.com in the browser that never started my
app.
It gets started when a matching link is clicked not when you type the url in the browser.
Try it by sending yourself an email containing http://ebay.com and click the link in the email application.

Link to an android application from SMS/mail

I would like to know if we can have a link in a SMS that would be handle by my application. For example a link which would look like myapp://blabla. And by clicking on it myapp would be open with the link as an argument.
This question also refers to email, either from a file with a special extension or a link like in the SMS.
Thanks a lot for your help.
Edit 31/01
Actually, I did what Greg suggested it but it doesn't work. Such a link (myapp://blabla) is not clickable in a SMS/email...When I replace myapp with http as a scheme, it works (Android asks me wether it should open the link with myapp or the browser). But myapp://blabla isn't clickable with myapp as a scheme.
Here is my code:
<application android:icon="#drawable/icon" android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".myapp"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="myapp" android:host="blabla" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity"></activity>
<activity android:name=".SettingsActivity"></activity>
</application>
Yep you can with an intent filter.
Basically in your android Manifest, choose an activity that you want to be the one that handles the given url.
<activity android:name=".myactivies.MyActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="myapp" android:host="blabla" />
</intent-filter>
</activity>
Then inside your activity you can get the url by calling getData() on the intent.

Categories

Resources