鄙人小菜一枚,最近做开发时,遇到一个问题。自己的程序中有个Activity,在Manifest对应项中,exported设置为false,在该activity项下设置了intent filter规则,具体见后续代码。手机在安装了自己的程序后,在文件管理器里打开文本文件时,每次都弹出选择打开方式的对话框,即使设置了“始终”。
当exported为true时,是正常的;当exported为false,注释掉intentfilter时,也是正常的;只有当exported为false,intent filter规则未注释掉时,才会出现这个问题。Android4.2和Android4.3上都会出现这个问题,其他系统版本没测。
下面是自己做的一个简单的问题示例,就是通过eclipse默认生成了一个hello world,在Manifest下加入了intentfilter规则。求解!!!有木有遇到过类似情形的?
当exported为true时,是正常的;当exported为false,注释掉intentfilter时,也是正常的;只有当exported为false,intent filter规则未注释掉时,才会出现这个问题。Android4.2和Android4.3上都会出现这个问题,其他系统版本没测。
下面是自己做的一个简单的问题示例,就是通过eclipse默认生成了一个hello world,在Manifest下加入了intentfilter规则。求解!!!有木有遇到过类似情形的?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.xizi"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.test.xizi.MainActivity"
android:label="@string/app_name"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:host="" android:scheme="file" android:mimeType="text/plain"/>
<data android:pathPattern=".*\\.epub"/>
<data android:pathPattern=".*\\.oeb"/>
<data android:pathPattern=".*\\.fb2"/>
<data android:pathPattern=".*\\.mobi"/>
<data android:pathPattern=".*\\.prc"/>
<data android:pathPattern=".*\\.txt"/>
<data android:pathPattern=".*\\.rtf"/>
</intent-filter>
</activity>
</application>
</manifest>