Hi everyone,
here's my scenario: I start an Activity A via an AppWidget. The AppWidget displays (inter alia) 3 buttons. Each of them has its own intent. They are designed to provide information to the Activity via a class called AppWidgetReceiver. In latter I create an intent like this:
Intent i = new Intent(context, CreateNoteActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra(AppWidget.WIDGET_ITS_TRIGGER_ID, trigger_id);
i.putExtra(AppWidget.WIDGET_TITLE, title);
i.putExtra(AppWidget.WIDGET_DESCRIPTION, descr);
context.startActivity(i);
This launches the Activity A. Based on trigger_id
, title
and descr
I create some sort of information menu for the user:
coreQuestionTitle = getIntent().getStringExtra(AppWidget.WIDGET_TITLE);
coreQuestionDescr = getIntent().getStringExtra(AppWidget.WIDGET_DESCRIPTION);
coreQuestionId = getIntent().getIntExtra(AppWidget.WIDGET_ITS_TRIGGER_ID, -1);
TextView tvCoreQuestion = (TextView) findViewById(R.id.create_note_core_question_text);
tvCoreQuestion.setText(coreQuestionTitle);
All of this works fine. The problem arises when I don't 'close' the Activity via this.finish()
, e.g. the home- or back-button is pressed. When I now click on an OTHER button on the AppWidget the previously opened Activity is restored instead of restarted. The onCreate()
is not called. Instead, it jumps right into onStart()
. I know that this is intended by the Activity lifecycle since the task is still alive.
Unfortunately, I really need to be able to retrieve the parameters specified in the intent to set the desired information. Moreover, I would like to be able to restore the state of ANY of 3 different tasks. Can anyone help me out on this?
By the way: I'm avoiding to pass the onCreate()
by making use of android:configChanges="keyboardHidden|orientation" and onConfigurationChanged()
. The declaration of the Activity in the Manifest.xml looks like this:
<activity android:name=".notes.CreateNoteActivity"
android:configChanges="keyboardHidden|orientation"
android:label="@string/create_note"
android:launchMode="singleTask"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<category android:name="android.intent.category.CATEGORY_HOME" />
</intent-filter>
</activity>
Thanks in advance,
Steff