In your AndroidManifest.xml
, you need to add the following XML
as a child of your Activity
, which will add an Intent Filter (you don't need to know anything more than that):
<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="https" android:host="mysite.com" />
</intent-filter>
Then, in your main Java
file, where you call a line like this:
super.loadUrl(“file:///android_asset/www/index.html”);
add the following code (after the line above):
try {
Uri uri = getIntent().getData();
String data = uri.getSchemeSpecificPart();//this will set data to //mysite.com/iphoneopen.php?verification=XXXXXXXXX&username=larry
if (data != null) {
String[] vars = data.split("?");
vars = vars[1].split("&");
String verification = vars[0].split("=")[1];
String username = vars[1].split("=")[1];
//TODO: handle verification and username from here.
}
} catch (Throwable t) {
t.printStackTrace();
}