最近使用したアプリの一覧から活動を開きます選択して共有オプションが選択されている、私のアプリが一覧表示され、活動の新しいインスタンスがあるとき、意向私はonDestroyを(呼び出すたびに作成)と私は起動モード<strong>singleTask</strong>でアプリを作成し、テキストがあるときに他のアプリからので、</strong><strong>text/plainのMIMEタイプのインテントフィルタを持つ
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (intent.ACTION_SEND.equals(action) && type != null) {
sharedData = FileHandler.handleSendText(intent);
}
}
@Override
protected void onNewIntent(Intent intent) {
String action = intent.getAction();
String type = intent.getType();
if (intent.ACTION_SEND.equals(action) && type != null) {
sharedData = FileHandler.handleSendText(intent);
}
super.onNewIntent(intent);
}
@Override
protected void onDestroy() {
if (android.os.Build.VERSION.SDK_INT >= 21) {
finishAndRemoveTask();
} else {
finish();
}
super.onDestroy();
}
私はアプリで奇妙な挙動を有する午前に従うようのonCreateとonNewIntent方法で着信コンテンツを扱います作成された入力テキストは、 sharedData可変スルーのonCreate方法及びアプリonDestroy方法は、(ボタンをバック押す)と呼ばれ、最近使用したアプリのアクティビティを開始したとき、のonCreate方法は正常であるが、これと呼ばれるIntent.getAction()とIntent.getType()も有効な値を返しています。なぜそれが起こっているのですか?
アフト私はインテントを取得し、アプリの場合、画面の向きを縦長から横長に変更すると、その逆もあります。** onCreate **メソッドが呼び出されるため、その場合** Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY **は0または1を返しますか? – TejaReddy
オリエンテーションの変更後に 'onCreate()'で取得した 'Intent'は、オリエンテーションが変更される前に' onCreate() 'で取得した' Intent'とまったく同じです。 –
また、** onDestroy **メソッドのrecentsからアクティビティをプログラムで除外し、** onCreate **メソッドのrecentsに再度含めるので、これはインテントフラグに影響しますか?ありがとう。 – TejaReddy