6
ImはSingleTaskで、 'testing'スキームを聞くことができるアプリケーションを持っています。私はボタンをクリックするとアプリケーションランチャーからのAndroid onNewIntentが私に最後のインテントを与えます
私は自分自身を再起動し、私は家にしてから押すとonNewIntentが今私に「テスト」の意図(今私はフラグメントを押してこれに反応するかもしれない)
を与えると呼ばれている(コードを参照してください)アプリケーションランチャーを開き、アプリケーションを再入力してください。私はonNewIntentを呼びたいと思いますが、空の意図で、私のアクション(例えば、プッシュフラグメント)をやり直したくありません。しかし、onNewIntentは私の活動を開始するために使用された最後の意図を私に与えています。これは「テスト」の意図です。
同じフラグメントをプッシュしないようにするにはどうすればよいですか?自分のIDを使わずにいい方法がありますか?
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())));
}
}