Skip to content

Instantly share code, notes, and snippets.

@SelvinPL
Last active January 3, 2017 23:17
Show Gist options
  • Save SelvinPL/19a9ab51d0567ecfd378622d68f1cd1f to your computer and use it in GitHub Desktop.
Save SelvinPL/19a9ab51d0567ecfd378622d68f1cd1f to your computer and use it in GitHub Desktop.
ProxyActivity
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example" >
<application
<!-- other Activities goes here -->
<activity
android:name=".ProxyActivity"
android:label="Some nice label"
android:noHistory="true"
android:theme="@android:style/Theme.NoDisplay">
<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="mywebsite.pl"/>
<data
android:scheme="http"
android:host="www.mywebsite.pl"/>
</intent-filter>
</activity>
</application>
</manifest>
package com.example;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Toast;
public class ProxyActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent intent = getIntent();
if (intent != null) {
Uri uri = intent.getData();
if (uri != null) {
if (TextUtils.isEmpty(uri.getPath()) || uri.getPath().equals("/")) {
Toast.makeText(this, "Starting HomeActivity", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Starting SpecialActivity for path: " + uri.getPath(), Toast.LENGTH_SHORT).show();
}
}
}
finish();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment