- Home /
How do I launch my Unity game from a URL in Android?
I've managed to launch my app from Safari using a custom URL type in an iOS build, and I pass that URL into the PlayerPrefs by using some code in AppController.mm.
How can I do the same thing on an Android build, launching my app to handle a custom URL scheme, and passing that URL into PlayerPrefs?
Oh hey, you're Simon Wittber! I remember you back from pyweek. I didn't notice it was you when I wrote my answer. Last place I was expecting to see a familiar name from the python community.
Answer by Cake · Jul 10, 2013 at 05:12 PM
You'll need to use the Android intent android.intent.category.BROWSABLE.
The example Android app Photostream does this.
In its AndroidManifest.xml you can see where it sets up the intent:
<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="flickr.com"
android:pathPrefix="/photos/" />
<data android:scheme="http"
android:host="www.flickr.com"
android:pathPrefix="/photos/" />
</intent-filter>
You can see the data being retrieved from the intent in PhotostreamActivity in the getUser function.
You can do something like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Uri uriUsedToLaunch = getIntent().getData();
}
Excellent I will try this out and accept if it works! Thankyou!
Did you get a chance to try it out? I've never actually done this, I'm rather curious if it works.
Your answer
Follow this Question
Related Questions
Open a local html file in the Android's default browser 1 Answer
cant open the google play app? 0 Answers
Open Android App from URL 3 Answers
Android activity is restarting instead of pause/resuming... 0 Answers
Android app stuck opening url 0 Answers