我想改变应用程序的主题,问题是当我重新创建()活动时,应用程序变白,直到它内存不足。 当我删除Sqlite DB处理程序时,它运行完美。 如果你能指出正确的方向那就太好了!
if(bundle.getBoolean("anss")==true){
SharedPreferences.Editor editor= settings.edit();
editor.putString("theme","zebra");
editor.commit();//Intent i = new Intent(this, MainActivity.class);
// i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// this.finish();
// this.startActivity(i);
// myDBHandler.close();
recreate();
}
感谢。
编辑:我默认在sql中添加一些数据,只要sqlite数据库是空的,现在有问题,但如果用户添加了应用程序再次崩溃的东西,我认为它是因为我使用recreate()或finish( )。12-28 22:36:33.091 17463-17463/thehuntest.com.beta E/art: Throwing OutOfMemoryError "Failed to allocate a 28 byte allocation with 4 free bytes and 4B until OOM" (recursive case)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: "main" prio=5 tid=1 Runnable
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: | group="main" sCount=1 dsCount=0 obj=0x73dfc000 self=0xb8c902e8
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: | sysTid=17463 nice=0 cgrp=default sched=0/0 handle=0xb6fe4bec
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: | state=R schedstat=( 17721986814 2692679225 8127 ) utm=1660 stm=112 core=0 HZ=100
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: | stack=0xbe44a000-0xbe44c000 stackSize=8MB
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: | held mutexes= "mutator lock"(shared held)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #00 pc 00004e64 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #01 pc 00003665 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #02 pc 00256401 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+84)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #03 pc 00237a5b /system/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+150)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #04 pc 0023ae93 /system/lib/libart.so (art::Thread::ThrowOutOfMemoryError(char const*)+274)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #05 pc 001459b9 /system/lib/libart.so (art::gc::Heap::ThrowOutOfMemoryError(art::Thread*, unsigned int, art::gc::AllocatorType)+832)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #06 pc 00147979 /system/lib/libart.so (art::gc::Heap::AllocateInternalWithGc(art::Thread*, art::gc::AllocatorType, unsigned int, unsigned int*, unsigned int*, art::mirror::Class**)+668)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #07 pc 000fe3a7 /system/lib/libart.so (???)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #08 pc 0023a661 /system/lib/libart.so (art::Thread::ThrowNewWrappedException(art::ThrowLocation const&, char const*, char const*)+504)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #09 pc 0023aeff /system/lib/libart.so (art::Thread::ThrowOutOfMemoryError(char const*)+382)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #10 pc 001459b9 /system/lib/libart.so (art::gc::Heap::ThrowOutOfMemoryError(art::Thread*, unsigned int, art::gc::AllocatorType)+832)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #11 pc 00147979 /system/lib/libart.so (art::gc::Heap::AllocateInternalWithGc(art::Thread*, art::gc::AllocatorType, unsigned int, unsigned int*, unsigned int*, art::mirror::Class**)+668)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #12 pc 001f52a7 /system/lib/libart.so (art::mirror::String::Alloc(art::Thread*, int)+1310)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #13 pc 001f5519 /system/lib/libart.so (art::mirror::String::AllocFromUtf16(art::Thread*, int, unsigned short const*, int)+44)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #14 pc 001bea87 /system/lib/libart.so (???)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #15 pc 000bdc8b /system/lib/libart.so (???)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #16 pc 00074af3 /system/lib/libandroid_runtime.so (???)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: native: #17 pc 0084ce63 /data/dalvik-cache/arm/system@framework@boot.oat (Java_android_database_CursorWindow_nativeGetString__JII+110)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.database.CursorWindow.nativeGetString(Native method)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.database.CursorWindow.getString(CursorWindow.java:438)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at thehuntest.com.beta.MyDBHandler.tits(MyDBHandler.java:94)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at thehuntest.com.beta.MainActivity.reset(MainActivity.java:131)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at thehuntest.com.beta.MainActivity.onCreate(MainActivity.java:106)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.app.Activity.performCreate(Activity.java:5990)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3947)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.app.ActivityThread.access$900(ActivityThread.java:151)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.os.Handler.dispatchMessage(Handler.java:102)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.os.Looper.loop(Looper.java:135)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at android.app.ActivityThread.main(ActivityThread.java:5254)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at java.lang.reflect.Method.invoke!(Native method)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at java.lang.reflect.Method.invoke(Method.java:372)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
12-28 22:36:33.134 17463-17463/thehuntest.com.beta E/art: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Performing pause of activity that is not resumed: {thehuntest.com.beta/thehuntest.com.beta.MainActivity}
java.lang.RuntimeException: Performing pause of activity that is not resumed: {thehuntest.com.beta/thehuntest.com.beta.MainActivity}
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3231)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3219)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3194)
at android.app.ActivityThread.access$1000(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1314)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
答案 0 :(得分:0)
也许你有开光标。 使用下一个结构:
Cursor cursor = null;
try {
cursor = getCursor();
if (cursor.moveToFirst) {
//your commands
}
} finally {
if (cursor != null) {
cursor.close();
}
}