getBoolean之后的java.lang.ClassCastException

时间:2018-09-24 14:01:31

标签: java android

我在Google Play控制台中收到了此崩溃报告,但我在自己的设备上没有遇到该崩溃报告。

java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2594)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2685)
  at android.app.ActivityThread.access$900 (ActivityThread.java:188)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1530)
  at android.os.Handler.dispatchMessage (Handler.java:111)
  at android.os.Looper.loop (Looper.java:210)
  at android.app.ActivityThread.main (ActivityThread.java:5833)
  at java.lang.reflect.Method.invoke (Method.java)
  at java.lang.reflect.Method.invoke (Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1113)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:879)
Caused by: java.lang.ClassCastException: 
  at android.app.SharedPreferencesImpl.getBoolean (SharedPreferencesImpl.java:260)
  at .Dictionary.onCreate (Dictionary.java)
  at android.app.Activity.performCreate (Activity.java:6177)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1112)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2541)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2685)
  at android.app.ActivityThread.access$900 (ActivityThread.java:188)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1530)
  at android.os.Handler.dispatchMessage (Handler.java:111)
  at android.os.Looper.loop (Looper.java:210)
  at android.app.ActivityThread.main (ActivityThread.java:5833)
  at java.lang.reflect.Method.invoke (Method.java)
  at java.lang.reflect.Method.invoke (Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1113)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:879)

这是我在onCreate中的Dictionary.java中的一部分,我怀疑这是问题的根源。但是,我自己没有任何问题。我不明白为什么它会在某些设备上崩溃。

SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
boolean mCoinCount = settings.getBoolean("mCoinCount", false);

        mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView);
        mRecyclerView.setHasFixedSize(true);
        if (mCoinCount) {
            mAdapter = new MyAdapter(TITLES, ICONS, NAME, this);
        } else {
            mAdapter = new MyAdapter(NTITLES, NICONS, NAME, this);
        }
        mRecyclerView.setAdapter(mAdapter);
        final GestureDetector mGestureDetector = new GestureDetector(Dictionary.this, new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onSingleTapUp(MotionEvent e) {
                return true;
            }
        });

以前,我不是getBoolean的{​​{1}}人。因此,我不会遇到这次崩溃。

SharedPreferences

0 个答案:

没有答案