安卓:试图调用preferences.java时强制关闭 [英] Android: Force close when trying to call Preferences.java

查看:317
本文介绍了安卓:试图调用preferences.java时强制关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一直试图通过调用preferences.java类:

Been trying to call Preferences.java class using:

Intent settingsActivity = new Intent(getBaseContext(), Preferences.class);
startActivity(settingsActivity);

我有这个在我的Manifest.xml(主应用类的活动外):

I have this in my Manifest.xml (outside the main app class activity):

<application>
   ........

    <activity android:name=".Preferences" android:label="Preferences">

      </activity>
    </application>

和我仍然得到强制关闭了android.content.ActivityNotFound ......

And I still get force close for "android.content.ActivityNotFound..." :

E/AndroidRuntime(25644): FATAL EXCEPTION: main
E/AndroidRuntime(25644): android.content.ActivityNotFoundException: Unable to fi
nd explicit activity class {com./java.util.prefs.Preferences};
 have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime(25644):        at android.app.Instrumentation.checkStartActivit
yResult(Instrumentation.java:1404)
E/AndroidRuntime(25644):        at android.app.Instrumentation.execStartActivity
(Instrumentation.java:1378)
E/AndroidRuntime(25644):        at android.app.Activity.startActivityForResult(A
ctivity.java:2817)
E/AndroidRuntime(25644):        at android.app.Activity.startActivity(Activity.j
ava:2923)
E/AndroidRuntime(25644):        at com.droidil.droidmarks.Dmarks.onOptionsItemSe
lected(Dmarks.java:337)
E/AndroidRuntime(25644):        at android.app.Activity.onMenuItemSelected(Activ
ity.java:2195)
E/AndroidRuntime(25644):        at com.android.internal.policy.impl.PhoneWindow.
onMenuItemSelected(PhoneWindow.java:730)
E/AndroidRuntime(25644):        at com.android.internal.view.menu.MenuItemImpl.i
nvoke(MenuItemImpl.java:143)
E/AndroidRuntime(25644):        at com.android.internal.view.menu.MenuBuilder.pe
rformItemAction(MenuBuilder.java:855)
E/AndroidRuntime(25644):        at com.android.internal.view.menu.IconMenuView.i
nvokeItem(IconMenuView.java:532)
E/AndroidRuntime(25644):        at com.android.internal.view.menu.IconMenuItemVi
ew.performClick(IconMenuItemView.java:122)
E/AndroidRuntime(25644):        at android.view.View$PerformClick.run(View.java:
8818)
E/AndroidRuntime(25644):        at android.os.Handler.handleCallback(Handler.jav
a:587)
E/AndroidRuntime(25644):        at android.os.Handler.dispatchMessage(Handler.ja
va:92)
E/AndroidRuntime(25644):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(25644):        at android.app.ActivityThread.main(ActivityThrea
d.java:4627)
E/AndroidRuntime(25644):        at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(25644):        at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime(25644):        at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(25644):        at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:626)
E/AndroidRuntime(25644):        at dalvik.system.NativeStart.main(Native Method)

没有编译错误......眼前这个运行时错误...
任何想法,为什么它是强制关闭,即使我有在manifest.xml中定义的活动?

No Compiling errors... just this Runtime error... Any ideas why it's force closing even though I have the Activity defined in the Manifest.xml?

鸭preciate任何帮助!

Appreciate any help!

推荐答案

它看起来像你有一个import语句混淆。看看关于第二行的java.util。preFS。preferences。要么改变你的进口或完全限定您参考您的preference活动。

It looks like you have an import statement mix-up. Look at the 2nd line about "java.util.prefs.Preferences". Either change your imports or fully qualify your reference to your Preference activity.

这篇关于安卓:试图调用preferences.java时强制关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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