Issue
I have one activity which forms the basis of my application. Here is the problem.
- I create an activity instance called
Instance1
. - My activity is then sent to the background by navigating back to the home menu.
onPause
andonStop
are called onInstance1
. - I then navigate to
Gmail
and open an emails attachment. - This creates a new instance of my activity 'Instance2` (I know this because I log what the instance is). Anything I do now within my activity is within this new instance.
- If I then navigate out and to gmail,
onDestroy
is called onInstance2
then if I open my application by touching the icon the originalInstance1
onRestart
is called.
Here is my intent filter inside my manifest.xml
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.dog" />
</intent-filter>
I have also added the following to my Applications tag in the manifest file but it has no effect.
android:launchMode="singleTask"
Question
Why can't it realise there is an instance running and open that?
ADDITION
I used singleInstance and moved it into my Activity tag. However, now I can't get my email attachments data? Previously I used the following.
Intent intent = getIntent();
if (intent != null) {
Log.d("MainActivity","Intent not null");
Uri u = intent.getData();
if (u != null) {
Log.d("MainActivity","URI not null");
Solution
The launchMode tag is part of the <activity>
element, not the application element.
You should use singleTop to re-use the existing activity.
Answered By - David Snabel-Caunt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.