I would like to recover the android intent my activity is launched with.
My activity, tested in API 19 (KitKat), besides the main intent, has the following intent filter and parameters:
android:alwaysRetainTaskState="false"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.svg" />
<data android:host="*" />
</intent-filter>
But when I open a SVG file while the activity was running, it does not handle the new intent. I tried the following combinations, launched the activity,
android:launchMode="singleTask"
android:launchMode="standard"
android:launchMode="singleTop"
combined with the following parameter, that makes 6 configurations
android:finishOnTaskLaunch="true" or "false"
But none of them make the onNewIntent
function to be called when I open a SVG with my application. Instead, it displays the previous state (onPause and onResume are called as expected, and onCreate is called instead).
The only workaround I found was to cal the finish()
function from withing the onPause()
method, so that it effectively terminates the application. I don't understand what is going on because it was working last year before I changed targets.
What is the required configuration to access the calling intents each time?
Related questions without answers to mine:
For the moment, my program works well and loads SVG as I wanted. Some points about my configuration (maybe it can help)
android:finishOnTaskLaunch="true"
in the AndroidManifest.xml
finish()
in the onPause()
methodOnNewIntent
is never called, but the onCreate
method is called which parse the new intent.The content of the activity manifest is the following:
<activity
android:name="com.example.mypackage"
android:launchMode="singleTop"
android:finishOnTaskLaunch="true"
android:alwaysRetainTaskState="false"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.svg" />
<data android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>