2013-04-09 224 views
0

我無法弄清爲什麼我的應用程序是關閉屏幕時強行關閉,這是logcat 我的應用程序具有滾動文本,顯示小部件,獲取用戶位置,有傳呼機,獲取當前時間,獲取電池電量,所以代碼相當長,所以現在我只會發布logcat,也許你可以通過這個數字找出問題 如果你需要一些代碼讓我知道當關閉屏幕時,應用程序強制關閉

04-09 02:57:56.498: D/Evolution Launcher(16574): Stopping 
04-09 02:57:56.623: W/IInputConnectionWrapper(16574): getExtractedText on inactive InputConnection 
04-09 02:57:56.639: W/IInputConnectionWrapper(16574): getTextBeforeCursor on inactive InputConnection 
04-09 02:57:56.655: W/IInputConnectionWrapper(16574): getSelectedText on inactive InputConnection 
04-09 02:57:56.662: W/IInputConnectionWrapper(16574): getTextAfterCursor on inactive InputConnection 
04-09 02:57:56.670: W/IInputConnectionWrapper(16574): getExtractedText on inactive InputConnection 
04-09 02:57:56.670: W/IInputConnectionWrapper(16574): getTextBeforeCursor on inactive InputConnection 
04-09 02:57:56.850: D/dalvikvm(16574): GC_EXPLICIT freed 1120K, 6% free 20548K/21696K, paused 3ms+13ms, total 140ms 
04-09 02:57:56.959: W/IInputConnectionWrapper(16574): getExtractedText on inactive InputConnection 
04-09 02:57:57.053: W/ResourceType(16574): Failure getting entry for 0x7f030004 (t=2 e=4) in package 0 (error -75) 
04-09 02:57:57.053: D/AndroidRuntime(16574): Shutting down VM 
04-09 02:57:57.053: W/dalvikvm(16574): threadid=1: thread exiting with uncaught exception (group=0x41356930) 
04-09 02:57:57.069: E/AndroidRuntime(16574): FATAL EXCEPTION: main 
04-09 02:57:57.069: E/AndroidRuntime(16574): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.doublep.evolution/com.doublep.evolution.LauncherActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030004 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3692) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.access$700(ActivityThread.java:141) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1240) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.os.Handler.dispatchMessage(Handler.java:99) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.os.Looper.loop(Looper.java:137) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.main(ActivityThread.java:5041) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at java.lang.reflect.Method.invokeNative(Native Method) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at java.lang.reflect.Method.invoke(Method.java:511) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at dalvik.system.NativeStart.main(Native Method) 
04-09 02:57:57.069: E/AndroidRuntime(16574): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030004 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.content.res.Resources.getValue(Resources.java:1014) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2139) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.content.res.Resources.getLayout(Resources.java:853) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.view.LayoutInflater.inflate(LayoutInflater.java:394) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.Activity.setContentView(Activity.java:1881) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at com.doublep.evolution.LauncherActivity.onCreate(LauncherActivity.java:455) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.Activity.performCreate(Activity.java:5104) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 
04-09 02:57:57.069: E/AndroidRuntime(16574): ... 12 more 
04-09 02:57:57.116: I/Process(16574): Sending signal. PID: 16574 SIG: 9 

我已經將setContentView更改爲不同的佈局(不同的文件,從舊的複製的內容) 它給了我一個不同的力關閉

04-09 03:34:25.514: D/dalvikvm(18864): GC_EXPLICIT freed 1259K, 6% free 20440K/21728K, paused 2ms+7ms, total 36ms 
04-09 03:34:28.553: D/Evolution Launcher(18864): Stopping 
04-09 03:34:28.756: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection 
04-09 03:34:28.772: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection 
04-09 03:34:28.780: W/IInputConnectionWrapper(18864): getSelectedText on inactive InputConnection 
04-09 03:34:28.780: W/IInputConnectionWrapper(18864): getTextAfterCursor on inactive InputConnection 
04-09 03:34:28.780: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection 
04-09 03:34:28.787: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection 
04-09 03:34:28.795: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection 
04-09 03:34:28.795: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection 
04-09 03:34:28.803: W/IInputConnectionWrapper(18864): getSelectedText on inactive InputConnection 
04-09 03:34:28.803: W/IInputConnectionWrapper(18864): getTextAfterCursor on inactive InputConnection 
04-09 03:34:28.811: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection 
04-09 03:34:28.819: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection 
04-09 03:34:28.819: W/IInputConnectionWrapper(18864): getSelectedText on inactive InputConnection 
04-09 03:34:28.826: W/IInputConnectionWrapper(18864): getTextAfterCursor on inactive InputConnection 
04-09 03:34:28.834: W/IInputConnectionWrapper(18864): beginBatchEdit on inactive InputConnection 
04-09 03:34:28.834: W/IInputConnectionWrapper(18864): endBatchEdit on inactive InputConnection 
04-09 03:34:28.834: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection 
04-09 03:34:28.834: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection 
04-09 03:34:28.842: W/IInputConnectionWrapper(18864): getSelectedText on inactive InputConnection 
04-09 03:34:28.842: W/IInputConnectionWrapper(18864): getTextAfterCursor on inactive InputConnection 
04-09 03:34:28.858: W/IInputConnectionWrapper(18864): beginBatchEdit on inactive InputConnection 
04-09 03:34:28.858: W/IInputConnectionWrapper(18864): endBatchEdit on inactive InputConnection 
04-09 03:34:29.569: D/dalvikvm(18864): GC_FOR_ALLOC freed 1154K, 7% free 21232K/22604K, paused 51ms, total 66ms 
04-09 03:34:29.819: D/dalvikvm(18864): GC_FOR_ALLOC freed 201K, 7% free 23846K/25416K, paused 25ms, total 25ms 
04-09 03:34:30.170: D/dalvikvm(18864): GC_FOR_ALLOC freed 3K, 6% free 26556K/28128K, paused 21ms, total 24ms 
04-09 03:34:30.420: D/Evolution Launcher(18864): Loading variables 
04-09 03:34:30.420: D/Evolution Launcher(18864): Restoring prefs 
04-09 03:34:30.420: D/Evolution Launcher(18864): Screen density actions 
04-09 03:34:30.467: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection 
04-09 03:34:30.475: I/Choreographer(18864): Skipped 71 frames! The application may be doing too much work on its main thread. 
04-09 03:34:30.631: E/ActivityThread(18864): Activity com.doublep.evolution.LauncherActivity has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? 
04-09 03:34:30.631: E/ActivityThread(18864): android.app.IntentReceiverLeaked: Activity com.doublep.evolution.LauncherActivity has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? 
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:795) 
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:596) 
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1316) 
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1296) 
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1290) 
04-09 03:34:30.631: E/ActivityThread(18864): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:423) 
04-09 03:34:30.631: E/ActivityThread(18864): at com.doublep.evolution.LauncherActivity.batteryLevel(LauncherActivity.java:144) 
04-09 03:34:30.631: E/ActivityThread(18864): at com.doublep.evolution.LauncherActivity.access$0(LauncherActivity.java:116) 
04-09 03:34:30.631: E/ActivityThread(18864): at com.doublep.evolution.LauncherActivity$1.run(LauncherActivity.java:985) 
04-09 03:34:30.631: E/ActivityThread(18864): at android.os.Handler.handleCallback(Handler.java:725) 
04-09 03:34:30.631: E/ActivityThread(18864): at android.os.Handler.dispatchMessage(Handler.java:92) 
04-09 03:34:30.631: E/ActivityThread(18864): at android.os.Looper.loop(Looper.java:137) 
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.ActivityThread.main(ActivityThread.java:5041) 
04-09 03:34:30.631: E/ActivityThread(18864): at java.lang.reflect.Method.invokeNative(Native Method) 
04-09 03:34:30.631: E/ActivityThread(18864): at java.lang.reflect.Method.invoke(Method.java:511) 
04-09 03:34:30.631: E/ActivityThread(18864): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
04-09 03:34:30.631: E/ActivityThread(18864): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
04-09 03:34:30.631: E/ActivityThread(18864): at dalvik.system.NativeStart.main(Native Method) 
04-09 03:34:30.701: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection 
04-09 03:34:30.701: D/AndroidRuntime(18864): Shutting down VM 
04-09 03:34:30.701: W/dalvikvm(18864): threadid=1: thread exiting with uncaught exception (group=0x41356930) 
04-09 03:34:30.709: E/AndroidRuntime(18864): FATAL EXCEPTION: main 
04-09 03:34:30.709: E/AndroidRuntime(18864): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.BATTERY_CHANGED flg=0x60000010 (has extras) } in [email protected] 
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:768) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.os.Handler.handleCallback(Handler.java:725) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.os.Handler.dispatchMessage(Handler.java:92) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.os.Looper.loop(Looper.java:137) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.app.ActivityThread.main(ActivityThread.java:5041) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at java.lang.reflect.Method.invokeNative(Native Method) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at java.lang.reflect.Method.invoke(Method.java:511) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at dalvik.system.NativeStart.main(Native Method) 
04-09 03:34:30.709: E/AndroidRuntime(18864): Caused by: java.lang.IllegalArgumentException: Receiver not registered: [email protected] 
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:657) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1339) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:445) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at com.doublep.evolution.LauncherActivity$4.onReceive(LauncherActivity.java:121) 
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:758) 
04-09 03:34:30.709: E/AndroidRuntime(18864): ... 9 more 
04-09 03:34:30.741: I/Process(18864): Sending signal. PID: 18864 SIG: 9 

如果您看到日誌「停止」這是當我關掉屏幕,在那裏你看到「加載變量」,它是在OnCreate,所以它的意思是這一次它重新啓動,但崩潰反正

UPDATE : 我的應用程序在橫向模式下運行,所以我的主要佈局是土地佈局內只,顯然第一logcat的是,當我只有山水,第二個是當我有它的縱向佈局

內更新2 0x7f0 30004是未使用,刪除它實施後的佈局叫做numpad.xml,價值得到了重新建立關聯的Settings.XML,同樣的問題

更新3 我註釋掉的廣播接收器,這是logcat的我得到 http://pastebin.com/CXYA7bJe

UPDATE 4部分解決 好,所以,第一logcat的是給我時,我只能以橫向有佈局,將其轉移到縱向解決的首要logcat的

第二logcat的是通過註釋掉的BroadcastReceiver

這是廣播接收器的樣子

batteryLevelReceiver = new BroadcastReceiver() { 
      public void onReceive(Context context, Intent intent) { 
       context.unregisterReceiver(this); 
       int rawlevel = intent.getIntExtra("level", -1); 
       int scale = intent.getIntExtra("scale", -1); 
       int level = -1; 
       if (rawlevel >= 0 && scale > 0) { 
        level = (rawlevel * 100)/scale; 
       } 
       if (animToBattery == true) { 
        if (animValue < level * 1.8) { 
         animValue = animValue +2; 
        } 
        else { 
         animToBattery = false; 
        } 
        ArcView.value = (float)(animValue); 
       } 
       else { 
        ArcView.value = (float)(level * 1.8); 
       } 

      } 
     }; 
     IntentFilter batteryLevelFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); 
     registerReceiver(batteryLevelReceiver, batteryLevelFilter); 

有什麼不對的地方解決了嗎? 我註銷它的onStop(),此外,我不知道這是什麼context.unregisterReceiver(this);是在那裏做,但刪除它並沒有解決任何問題

UPDATE 5 初始化變量

http://pastebin.com/PAuw5fmd

+0

當屏幕熄滅時,您是否開始進行任何活動?它說它無法在活動LauncherActivity.java中找到一個資源「資源ID#0x7f030004」:455' – 2013-04-09 01:15:43

+0

在455行我有setContentView(R.layout.launcher_main); launcher_main有一個包含在裏面 我沒有開始任何活動(我已經評論他們出來進行調試) – DoubleP90 2013-04-09 01:19:37

+0

您可能引用了您的'launcher_main'佈局中的一個資源,該資源在平臺版本的應用程序中不可用被執行。也可能是因爲您已將資源定義在具有特定限定符的文件夾中,以防止運行時環境加載該資源。 – 2013-04-09 01:43:49

回答

1

Caused by: java.lang.IllegalArgumentException: Receiver not registered: [email protected]

java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.BATTERY_CHANGED flg=0x60000010 (has extras) }似乎腥。如果電池電量發生變化,您是否確實註冊過廣播接收器?

Activity com.doublep.evolution.LauncherActivity has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()?

我靠着越來越趨向事實上,有與廣播接收器有問題。

首先logcat的

由logcat的再來看,我看到有一個資源未發現異常 - Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030004

檢查什麼R.java文件指向爲#0x7f030004,看看資源確實存在。

二logcat的

Caused by: java.lang.IllegalArgumentException: Receiver not registered: [email protected]

檢查,如果你已經註冊LauncherActivity接收器。

更新

嘗試使IntentFilter batteryLevelFilter全球然後初始化它batteryLevel。我假設這是由於Android無法識別Receiver的解析範圍。

+0

我現在沒有註冊它,但我仍然得到forceclosing,這次沒有關於broadcastReceiver的錯誤,所以它有幫助但仍然沒有解決問題 – DoubleP90 2013-04-09 02:21:55

+0

將新的logcat放到pastebin請把它與我們聯繫起來。 – 2013-04-09 02:26:44

+0

對不起,我錯了,我已經更新了這個問題,顯然第一個logcat是當我只有佈局內陸地佈局,第二個logcat是從我有肖像佈局時,這有點奇怪,我我仍然有相同的broadcastReceiver問題(只有當我有肖像佈局裏面的佈局) – DoubleP90 2013-04-09 02:33:11