2014-01-07 42 views
1

我想恢復我的活動啓動的Android意圖。API中的OnNewIntent 19 Android

我的活動,在API 19(KitKat)的測試,除了主力的意圖,有以下意圖過濾器和參數:

 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> 

但是當我打開SVG文件,而該活動正在運行,它不處理新的意圖。 我試過以下組合,推出的活動,

android:launchMode="singleTask" 

android:launchMode="standard" 

android:launchMode="singleTop" 

使用以下參數,這使得6個配置

android:finishOnTaskLaunch="true" or "false" 

但他們都不讓onNewIntent功能,當我打開一個被稱爲組合SVG與我的應用程序。相反,它會顯示以前的狀態(onPause和onResume按預期調用,而onCreate被調用)。

我發現的唯一的解決方法是從withing的onPause()方法,從而有效地終止應用程序CAL的finish()功能。我不明白髮生了什麼,因爲去年我改變了目標之前它正在工作。

每次訪問呼叫意圖所需的配置是什麼?

沒有回答相關的問題,以我的:

  • This blog解釋說,我應該使用「singleTop」,但它不是在我的情況下工作。
  • This SO question沒有任何答案。
  • This famous SO question描述了意圖的設置。但就我而言,我並不是自己創造這個意圖,而是android。
+0

你有沒有想出一個解決方案嗎? – CQM

+0

是的,看到我的答案,並感謝您的詢問。 –

回答

2

目前,我的程序運行良好,並加載了我想要的SVG。關於我的配置有些點(也許它可以幫助)

  • 我瞄準Android的API 15.我放棄了與19
  • 我在AndroidManifest.xml
  • 使用android:finishOnTaskLaunch="true"我不會在調用finish()onPause()方法
  • OnNewIntent永遠不會被調用,但會調用onCreate方法來解析新的意圖。
  • 活動清單的內容如下:

    <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>