Skip to content

Instantly share code, notes, and snippets.

@SelvinPL
Last active August 29, 2015 14:23
Show Gist options
  • Save SelvinPL/c2053f4c1ddc66bb1ec8 to your computer and use it in GitHub Desktop.
Save SelvinPL/c2053f4c1ddc66bb1ec8 to your computer and use it in GitHub Desktop.
It's working for me
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pl.selvin.android.sigletaskissingle">
<application
android:allowBackup="true"
android:label="SingleTaskIsSingleTask">
<activity
android:name=".Activities$ActivityA"
android:label="Activity A"
android:launchMode="singleTask">
<intent-filter>
<data android:scheme="xselvinpl" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Activities$ActivityB"
android:label="Activity B" />
</application>
</manifest>
package pl.selvin.android.sigletaskissingle;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class Activities {
public static class ActivityA extends Activity {
TextView textView = null;
@Override
protected void onCreate(Bundle icycle) {
super.onCreate(icycle);
textView = new TextView(this);
textView.setText("I'm a happy Activity A");
textView.append("\n\tstart data: " + getIntent().getData());
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent intent = new Intent(ActivityA.this, ActivityB.class);
startActivity(intent);
}
});
setContentView(textView);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
if (textView != null) {
textView.append("\n\tnew data: " + intent.getData());
}
}
}
public static class ActivityB extends Activity {
@Override
protected void onCreate(Bundle icycle) {
super.onCreate(icycle);
final TextView textView = new TextView(this);
textView.setText("I'm a happy Activity B");
setContentView(textView);
}
}
}
<html>
<body>
<a href="xselvinpl://test/aaa1">aaa1</a></br>
<a href="xselvinpl://test/aaa2">aaa2</a></br>
<a href="xselvinpl://test/bbb1">bbb1</a></br>
<a href="xselvinpl://test/ccc1">ccc1</a></br>
<a href="xselvinpl://test/ddd1">ddd1</a></br>
<a href="xselvinpl://test/eee1">eee1</a></br>
<a href="xselvinpl://test/fff1">fff1</a></br>
<a href="http://selvin.pl/cutomscheme.htm">orgin</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment