安卓:从preferences.xml开始活动 [英] Android: Start Activity from preferences.xml

查看:157
本文介绍了安卓:从preferences.xml开始活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从默认preferences.xml开始的活动,以<意图>标记。该活动是行之有效的,这个问题是不是与这一点。 (我伸出preferenceActivity在我的应用程序,所以preferences.xml是来与) 请看看code,有什么不对?

I would like to start an Activity from a default preferences.xml, with < intent > tag. The Activities are well tested, the problem is not with that. (I'm extending PreferenceActivity in my app, so the preferences.xml is "comes" with that) Please look at the code, what's wrong?

preferences.xml:

preferences.xml:

.... 
<PreferenceCategory 
    android:title="@string/titleEtcSetup">
    <PreferenceScreen
        android:key="renameCourses"
        android:title="@string/titleRenameCourses"
        android:summary="@string/textRenameDisplayedCoursesNames">
        <intent
             android:action="android.intent.action.VIEW"
             android:targetPackage="my.notifier.ui"
             android:targetClass="my.notifier.ui.EditCoursesNamesActivity" />         
    </PreferenceScreen>
.....
</PreferenceCategory>
..... 

manifest.xml的:

manifest.xml:

....
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.notifier.ui"....
....
<activity android:name=".EditCoursesNamesActivity" android:label="@string/titleRenameCourses">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
 .....

该活动并没有叫我preSS的renameCourses项目,没有任何反应。在LogCat中是明确的,没有任何错误或警告。我在寻找了很多,我没有找到一个解决办法,也许我只是错过了什么?请帮助!

The Activity isn't calling when I press the "renameCourses item", nothing happens. The LogCat is "clear", no errors or warnings. I was searching a lot, and I didn't find a solution, maybe I just missed something... Please help!

推荐答案

我有同样的问题。我得到这个工作只宣布我AndroidManifest.xml中的动作,因为这样:

I was having the same issue. I got this working by only declaring the action in my AndroidManifest.xml, as such:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.myapp" android:versionName="1.3" android:versionCode="4">

...

    <activity android:name=".activities.MyActivity" 
              android:label="@string/my_activity_title"
              android:theme="@android:style/Theme.Black.NoTitleBar">
        <intent-filter>
           <action android:name="com.example.myapp.activities.MyActivity" />
           <category android:name="android.intent.category.DEFAULT" />
       </intent-filter>
    </activity>

然后在我的preferences xml文件:

Then in my Preferences xml file:

<PreferenceCategory
        android:title="@string/my_activity_title">
    <PreferenceScreen
        android:title="@string/my_activity_title" 
        android:summary="@string/my_activity_title">
        <intent android:action="com.example.myapp.activities.MyActivity"/>
    </PreferenceScreen>
</PreferenceCategory>

这篇关于安卓:从preferences.xml开始活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆