首页 \ 问答 \ 启动时PreferenceManager.getDefaultSharedPreferences上的NullPointerException(NullPointerException at PreferenceManager.getDefaultSharedPreferences on startup)

启动时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
更新时间:2022-11-19 08:11

最满意答案

“更改”权限为“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 ...
  • 我的问题是,是否有可能以某种方式包含调用并在我的应用程序中使用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: ...
  • “更改”权限为“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 ...
  • 我引用了源页面 该工具被认为支持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中不是特定的安全风险。 如果您担心安全性,请确保将管道上的安全描述符设置为适当的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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)