Android 更改历史堆栈中活动的意图数据
我有一个可以处理“.arr”文件的应用程序。为此,我在AndroidManifest中添加了适当的参数:Android 更改历史堆栈中活动的意图数据,android,android-intent,back-stack,android-navigation,Android,Android Intent,Back Stack,Android Navigation,我有一个可以处理“.arr”文件的应用程序。为此,我在AndroidManifest中添加了适当的参数: <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="file" android
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.arr" android:mimeType="*/*"/>
</intent-filter>
问题在于,在历史堆栈中,它将意图与其数据(文件)一起保存。因此,如果我关闭我的应用程序并从历史记录中重新打开它,它会再次检测到好像我正在再次打开文件
我想将应用程序保留在历史堆栈中,但不包含文件信息 (更像是黑客而不是解决方案)您可以在SharedReferences中保存上次打开的文件的名称,在调用时检查它是否存在,并根据该名称进行设置…(更像是黑客而不是解决方案)您可以在SharedReferences中保存上次打开的文件的名称,在调用时检查它是否存在,然后根据该名称进行设置。。。
Uri uri = intent.getData();