启动时PreferenceManager.getDefaultSharedPreferences上的NullPointerException(NullPointerException at PreferenceManager.getDefaultSharedPreferences on startup)
所以我正在重新编写几个月前的应用程序(将故障排除在外,并让一些事情变得更好)但是现在我想到了一个我没有找到并且不知道它是什么的问题。 如果我在手机上运行应用程序,会发生此错误
01-20 22:37:46.595: E/AndroidRuntime(7350): FATAL EXCEPTION: main 01-20 22:37:46.595: E/AndroidRuntime(7350): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.stevedc.thinklogic/com.stevedc.thinklogic.TowerHanoi}: java.lang.NullPointerException 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1891) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread.access$600(ActivityThread.java:127) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.os.Handler.dispatchMessage(Handler.java:99) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.os.Looper.loop(Looper.java:137) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread.main(ActivityThread.java:4441) 01-20 22:37:46.595: E/AndroidRuntime(7350): at java.lang.reflect.Method.invokeNative(Native Method) 01-20 22:37:46.595: E/AndroidRuntime(7350): at java.lang.reflect.Method.invoke(Method.java:511) 01-20 22:37:46.595: E/AndroidRuntime(7350): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 01-20 22:37:46.595: E/AndroidRuntime(7350): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 01-20 22:37:46.595: E/AndroidRuntime(7350): at dalvik.system.NativeStart.main(Native Method) 01-20 22:37:46.595: E/AndroidRuntime(7350): Caused by: java.lang.NullPointerException 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:371) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:366) 01-20 22:37:46.595: E/AndroidRuntime(7350): at com.stevedc.thinklogic.TowerHanoi.<init>(TowerHanoi.java:42) 01-20 22:37:46.595: E/AndroidRuntime(7350): at java.lang.Class.newInstanceImpl(Native Method) 01-20 22:37:46.595: E/AndroidRuntime(7350): at java.lang.Class.newInstance(Class.java:1319) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.Instrumentation.newActivity(Instrumentation.java:1023) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1882)
有人能指出我需要看到哪个方向的故障吗?
So I'm remaking my application of A couple of months ago(getting the faults out, and making some things better) But now I came up on to A problem that I did'nt find and don't know what it is. If I"m running the application on my phone it give this error
01-20 22:37:46.595: E/AndroidRuntime(7350): FATAL EXCEPTION: main 01-20 22:37:46.595: E/AndroidRuntime(7350): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.stevedc.thinklogic/com.stevedc.thinklogic.TowerHanoi}: java.lang.NullPointerException 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1891) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread.access$600(ActivityThread.java:127) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.os.Handler.dispatchMessage(Handler.java:99) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.os.Looper.loop(Looper.java:137) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread.main(ActivityThread.java:4441) 01-20 22:37:46.595: E/AndroidRuntime(7350): at java.lang.reflect.Method.invokeNative(Native Method) 01-20 22:37:46.595: E/AndroidRuntime(7350): at java.lang.reflect.Method.invoke(Method.java:511) 01-20 22:37:46.595: E/AndroidRuntime(7350): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 01-20 22:37:46.595: E/AndroidRuntime(7350): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 01-20 22:37:46.595: E/AndroidRuntime(7350): at dalvik.system.NativeStart.main(Native Method) 01-20 22:37:46.595: E/AndroidRuntime(7350): Caused by: java.lang.NullPointerException 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:371) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:366) 01-20 22:37:46.595: E/AndroidRuntime(7350): at com.stevedc.thinklogic.TowerHanoi.<init>(TowerHanoi.java:42) 01-20 22:37:46.595: E/AndroidRuntime(7350): at java.lang.Class.newInstanceImpl(Native Method) 01-20 22:37:46.595: E/AndroidRuntime(7350): at java.lang.Class.newInstance(Class.java:1319) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.Instrumentation.newActivity(Instrumentation.java:1023) 01-20 22:37:46.595: E/AndroidRuntime(7350): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1882)
can somebody point me in the direction where I need to see wich the fault is?
原文:https://stackoverflow.com/questions/14429754
最满意答案
“更改”权限为“RXWD”(读取,执行,写入,删除)。 所以如果你删除该用户的删除权利,它应该工作。 确保您将此权限应用于文件夹,子文件夹和所有文件。 还要验证该用户的有效权限(例如,此用户不是其他某个组的其中一部分,他/她可能会获得额外的不需要的权限)
"Change" permission is "RXWD" (read, execute, write, delete). So if you remove the Delete right for that user it should work. Make sure you apply this permission to the folder, subfolders and all files. Also verify effective permissions for that this user (e.g. that this user is not part of some other group where he/she may get extra unwanted permissions)
相关问答
更多-
首先,您应该知道源的名称(这是事件查看器中的列,通常是写入事件日志信息的应用程序的名称)。 将System.Diagnostics名称空间引用添加到您的代码文件中: using System.Diagnostics 然后你必须创建一个EventLog的实例。 // First, check if event log contains required source if(EventLog.SourceExists("YourSourceName")) { // Specify your sourc ...
-
通用Windows应用程序和System.Security.Cryptography(Universal Windows Application & System.Security.Cryptography)[2022-06-12]
我的问题是,是否有可能以某种方式包含调用并在我的应用程序中使用System.Security.Cryptography? 或者我是否必须找到某种解决方法,以便它适用于UWP? 不,您不能在通用Windows平台应用程序中使用System.Security.Cryptography。 它包含在完整的.NET(桌面.NET)中,而UWP的.NET没有它。 Windows.Security.Cryptography.Core由Windows运行时提供,您可以在Windows运行时组件中使用它。 我担心你必须改变使 ... -
基本问题是您在基数10而不是十六进制中组合字节。 像这样修复追加线: sb.Append(hash[i].ToString("x2")); 然后,该方法为输入“1abcd1234”提供正确的值 ffd275c5130566a2916217b101f26150 如他们的文档中所述 。 The basic issue is that you are combining bytes in base 10 rather than hexadecimal. Fix the append line like so: ...
-
Windows安全(windows security)[2023-05-09]
“更改”权限为“RXWD”(读取,执行,写入,删除)。 所以如果你删除该用户的删除权利,它应该工作。 确保您将此权限应用于文件夹,子文件夹和所有文件。 还要验证该用户的有效权限(例如,此用户不是其他某个组的其中一部分,他/她可能会获得额外的不需要的权限) "Change" permission is "RXWD" (read, execute, write, delete). So if you remove the Delete right for that user it should work. Ma ... -
Microsoft发布了一组描述Windows Azure安全性的文档,您可以在这里找到: http : //msdn.microsoft.com/en-us/library/ff934690.aspx 你有特定的安全问题吗? Microsoft publishes a set of documents describing windows azure security which you can find here: http://msdn.microsoft.com/en-us/library/ff93 ...
-
首先澄清术语:通常由Spring Security中的角色组成的权限是应用程序范围的权限。 另一方面, ACL (访问控制列表)指定特定域对象的权限。 就像你了解差异一样。 AD通常包含权限/角色,但不包含ACL。 如果您不想使用AD中的权限,您可以自己实现UserDetailsContextMapper并将其注入您的ActiveDirectoryLdapAuthenticationProvider实例中。 请参阅Spring Security参考文档,了解如何指定自定义身份验证提供程序。 如果要使用引用模 ...
-
它们以完全信任 ( 源 )运行。 但是,它们使用Sandbox机制,因此某些API不可用(例如使用IPv6的套接字),或者不能按预期工作(例如, Socket.Available属性不可用,这限制了某些库的使用,例如作为NetFTP )。 如果您正在考虑将WA网站用于可能存在.NET安全问题的场景,我建议您与Microsoft支持部门取得联系,以确保此环境支持您可能需要的特定功能。 They run in Full Trust (source). However, they use a Sandbox me ...
-
如何在Windows 7下安装Skipfish Security扫描仪?(How to install Skipfish Security scanner under windows 7?)[2023-01-04]
我引用了源页面 该工具被认为支持Linux,FreeBSD,MacOS X和Windows(Cygwin)环境 由于它不是“真正的”Windows应用程序,因此您无法执行任何文件窗口(例如.exe或.msi文件)。 您需要使用http://www.cygwin.com/工具,然后或多或少地将其用作Linux应用程序。 阅读有关skipfish和Cygwin的说明,然后回答您可能遇到的任何更具体的问题。 I cite the source page The tool is believed to suppor ... -
这个帖子可以帮到你。 它描述了如何通过修改项目的AssemblyInfo.cs来避免异常。 虽然它没有解释为什么这只发生在Win 8 CP中。 您应该联系图表控件的开发人员。 This thread could help you. It describes how to avoid the exception by modifying the AssemblyInfo.cs of your project. Though it's not explaining why this just happens i ...
-
从安全的角度来看,管道在Windows中被认为是危险的吗?(Are pipes considered dangerous to use in Windows, from a security standpoint?)[2021-09-15]
管道在Windows中不是特定的安全风险。 如果您担心安全性,请确保将管道上的安全描述符设置为适当的DACL。 如果您的使用要求管道是开放的,任何人都可以连接,那么您必须将传入的数据视为可疑,就像任何文件或网络输入一样。 Pipes aren't a particular security risk in Windows. If you're worried about security, make sure you set the security descriptor on the pipe to an ...