Android打开文本文件,每次都弹出打开方式对话框

         鄙人小菜一枚,最近做开发时,遇到一个问题。自己的程序中有个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规则。求解!!!有木有遇到过类似情形的?
<?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>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值