PreferenceScreen启动活动

时间:2012-06-23 16:20:04

标签: android android-layout android-intent sharedpreferences

我有一项活动,我想从偏好设置屏幕加载。我收到以下错误:

06-23 16:12:00.470: E/AndroidRuntime(3410): android.content.ActivityNotFoundException:    Unable to find explicit activity class {com.polygonattraction.app/com.polygonattraction.app.functions.GetImageActivity}; have you declared this activity in your AndroidManifest.xml?

我的首选项屏幕代码:

         <PreferenceScreen 
        android:title="Get faces"
        android:summary="Get the faces.">

        <intent 
            android:targetClass="com.polygonattraction.app.functions.GetImageActivity"
            android:targetPackage="com.polygonattraction.app" 
         />
    </PreferenceScreen>

活动我想加载

public class GetImageActivity extends Activity 
{
public void onCreate()
{
    System.out.println("Started activity...");
            setContentView(R.layout.actilayout); //not done yet
}

}

这也是我的清单:

<uses-sdk android:minSdkVersion="7" />

<application 
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    >

    <service
        android:label="@string/app_name"
        android:name=".LiveService"        
        android:permission="android.permission.BIND_WALLPAPER"
        >

        <intent-filter android:priority="1">
            <action android:name="android.service.wallpaper.WallpaperService" />
        </intent-filter>

        <meta-data android:name="android.service.wallpaper" android:resource="@xml/wallpaper" />
    </service>

    <activity
        android:label="settings"
        android:name="com.polygonattraction.app.functions.Settings"
        android:exported="true">
    </activity>

</application>

我不擅长这个Android XML的东西,我习惯了trigga 2d图形编程。为什么他们这么乱?

3 个答案:

答案 0 :(得分:3)

在AndroidManifest文件中添加您的活动。

像这样:

<activity android:name=".GetImageActivity"  />

希望这有助于

答案 1 :(得分:1)

您已将活动声明为com.polygonattraction.app.functions.Settings,而实际名称似乎为com.polygonattraction.app.functions.GetImageActivity

尝试在清单中使用以下内容:

<activity
    android:label="settings"
    android:name="com.polygonattraction.app.functions.GetImageActivity"
    android:exported="true">
</activity>

而不是

<activity
    android:label="settings"
    android:name="com.polygonattraction.app.functions.Settings"
    android:exported="true">
</activity>

答案 2 :(得分:1)

在清单中为GetImageActivity创建条目,就像设置那样