Android Preference 中intent action的使用及出现的问题

来源:互联网 发布:决战武林进阶数据弩炮 编辑:程序博客网 时间:2024/06/06 20:22
<?xml version="1.0" encoding="utf-8"?><PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">    <Preference        android:key="progressBar"        android:title="@string/progressBar">       <intent           android:action="com.progress.views"/>    </Preference></PreferenceScreen>

在上面的xml中,想通过intent action 来指定对应的activity。

在AndroidMainfest.xml中

<activity android:name=".progress.ProgressActivity">      <intent-filter>          <action android:name="com.progress.views"/>      </intent-filter>   </activity>

运行后来时报错

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.progress.views }

后来发现必需添加

   <intent-filter>       <action android:name="com.progress.views"/>       <category android:name="android.intent.category.DEFAULT"/>   </intent-filter>
0 0
原创粉丝点击