Im having an application that is SingleTask and is able listen to the 'testing' scheme.
If I click the button (see code) I relaunch myself and onNewIntent is called giving me the 'testing' intent (Now I might react to this by pushing a fragment)
Now If I press home and then open the application launcher and re-enter my application I would like onNewIntent to be called but with an empty intent, beacause I dont want to redo my actions (for example pushing fragments). But onNewIntent is giving me the last intent that was used to launch my activity, which is the 'testing' intent.
What should I do to prevent pushing the same fragment? Is there a nice way without using my own ids.
public class OnNewIntentTestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.e("", "on create");
((Button) findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.e("", "Relaunch activity");
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("testing://hello")));
}
});
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.e("", "onNewIntent: " + (intent == null? "none" : (intent.getAction() + ":" + intent.getData())));
}
}