2012-07-17 78 views
0

我正在編程一個應用程序,我必須解決這個問題......在任何活動中,單擊主頁按鈕時手機會重新啓動,而我不會希望這種事情發生。Android:單擊主頁按鈕時避免手機重啓

我知道單擊主頁按鈕會將應用程序置於後臺,從Android生命週期中我會說OnPause被調用。也許我可以用這個OnPause()方法解決這個問題,但我不知道該怎麼做。

我已經包括在每個活動以下日誌:

07-17 19:40:20.556: V/ActivityManager(1378): destroyActivityLocked, com.android.server.am.ActivityStack.destroyActivityLocked(ActivityStack.java:3332) 
07-17 19:40:20.556: V/ActivityManager(1378): destroyActivityLocked, com.android.server.am.ActivityManagerService.trimApplications(ActivityManagerService.java:14511) 
07-17 19:40:20.556: V/ActivityManager(1378): destroyActivityLocked, com.android.server.am.ActivityManagerService.finishReceiver(ActivityManagerService.java:12421) 
07-17 19:40:20.556: V/ActivityManager(1378): destroyActivityLocked, android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:346) 
07-17 19:40:20.556: V/ActivityManager(1378): destroyActivityLocked, com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1642) 
07-17 19:40:20.566: V/ActivityManager(1378): destroyActivityLocked, android.os.Binder.execTransact(Binder.java:320) 
07-17 19:40:20.566: D/MyActivity(26362): MYonDestroy is called 
07-17 19:40:20.566: V/ActivityManager(1378): destroyActivityLocked, dalvik.system.NativeStart.run(Native Method) 
07-17 19:40:20.616: D/WindowManagerImpl(26362): finishRemoveViewLocked, mViews[0]: [email protected] 
07-17 19:40:20.716: D/libEGL(26672): loaded /system/lib/egl/libGLES_android.so 
07-17 19:40:20.726: D/WindowManagerImpl(1378): finishRemoveViewLocked, mViews[1]: [email protected] 
07-17 19:40:20.726: I/ActivityManager(1378): Displayed com.htc.launcher/.Launcher: +1s947ms 
07-17 19:40:20.776: D/libEGL(26672): loaded /system/lib/egl/libEGL_adreno200.so 
07-17 19:40:20.816: V/ActivityManager(1378): Checking to restart com.htc.launcher.Launcher: changed=0x0, handles=0x2a3 
07-17 19:40:20.816: V/ActivityManager(1378): oldConfig={ scale=1.0 imsi=214/1 loc=en_ES touch=3 keys=1/1/2 nav=1/1 orien=1 layout=34 uiMode=17 seq=657 skin=default fontsize=3} 
07-17 19:40:20.816: V/ActivityManager(1378): newConfig={ scale=1.0 imsi=214/1 loc=en_ES touch=3 keys=1/1/2 nav=1/1 orien=1 layout=34 uiMode=17 seq=657 skin=default fontsize=3} 
07-17 19:40:20.826: D/MyActivity(26362): MYonStop is called 
07-17 19:40:20.836: D/libEGL(26672): loaded /system/lib/egl/libGLESv1_CM_adreno200.so 
07-17 19:40:20.846: D/libEGL(26672): loaded /system/lib/egl/libGLESv2_adreno200.so 
07-17 19:40:20.936: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:20.946: I/RosieUtility(25755): disable self killer: mEnabled=1 
07-17 19:40:20.956: D/FxWidgetProvider(25755): row 4 
07-17 19:40:20.956: I/RosieUtility(25755): enable self killer: mEnabled=0 
07-17 19:40:20.966: D/WidgetProviderInfoCollector(26672): more than one style shared the same component! Return the first one found. 
07-17 19:40:21.276: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:21.286: I/RosieUtility(25755): disable self killer: mEnabled=1 
07-17 19:40:21.286: D/FxWidgetProvider(25755): row 1 
07-17 19:40:21.286: I/RosieUtility(25755): enable self killer: mEnabled=0 
07-17 19:40:21.326: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:21.336: I/RosieUtility(25755): disable self killer: mEnabled=1 
07-17 19:40:21.336: D/FxWidgetProvider(25755): row 1 
07-17 19:40:21.336: I/RosieUtility(25755): enable self killer: mEnabled=0 
07-17 19:40:21.476: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:21.476: I/RosieUtility(25755): disable self killer: mEnabled=1 
07-17 19:40:21.476: D/FxWidgetProvider(25755): row 1 
07-17 19:40:21.486: I/RosieUtility(25755): enable self killer: mEnabled=0 
07-17 19:40:21.577: D/szipinf(26672): Initializing inflate state 
07-17 19:40:22.047: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:22.047: I/RosieUtility(25755): disable self killer: mEnabled=1 
07-17 19:40:22.047: D/FxWidgetProvider(25755): row 1 
07-17 19:40:22.047: I/RosieUtility(25755): enable self killer: mEnabled=0 
07-17 19:40:22.417: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:22.427: I/RosieUtility(25755): disable self killer: mEnabled=1 
07-17 19:40:22.427: D/FxWidgetProvider(25755): row 1 
07-17 19:40:22.437: I/RosieUtility(25755): enable self killer: mEnabled=0 
07-17 19:40:22.477: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:22.477: I/RosieUtility(25755): disable self killer: mEnabled=1 
07-17 19:40:22.477: D/FxWidgetProvider(25755): row 1 
07-17 19:40:22.477: I/RosieUtility(25755): enable self killer: mEnabled=0 
07-17 19:40:22.908: D/dalvikvm(26672): GC_EXTERNAL_ALLOC freed 325K, 49% free 3739K/7303K, external 5261K/5309K, paused 39ms 
07-17 19:40:22.988: D/dalvikvm(26672): GC_EXTERNAL_ALLOC freed 13K, 49% free 3731K/7303K, external 5581K/6969K, paused 36ms 
07-17 19:40:23.178: D/dalvikvm(26672): GC_EXTERNAL_ALLOC freed 49K, 50% free 3681K/7303K, external 7187K/8975K, paused 39ms 
07-17 19:40:23.228: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:23.228: I/RosieUtility(25755): disable self killer: mEnabled=1 
07-17 19:40:23.228: D/FxWidgetProvider(25755): row 1 
07-17 19:40:23.238: I/RosieUtility(25755): enable self killer: mEnabled=0 
07-17 19:40:23.248: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:23.258: I/RosieUtility(25755): disable self killer: mEnabled=1 
07-17 19:40:23.258: D/FxWidgetProvider(25755): row 1 
07-17 19:40:23.258: I/RosieUtility(25755): enable self killer: mEnabled=0 
07-17 19:40:23.288: D/HomeLoaders(26672): --> starting applications loader 
07-17 19:40:23.428: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:23.478: E/mode10(26672): PlayMarker fail, marker 'intro_to_up' not found in button.shortcut 
07-17 19:40:23.508: E/mode10(26672): Fail to load timeline from asset. 
07-17 19:40:23.508: E/mode10(26672): Timeline load failure 
07-17 19:40:23.669: D/FxScreen(26672): item count: 1 
07-17 19:40:23.699: D/MessagingShortcutReceiver(25766): keep hiding shortcut bubble 
07-17 19:40:23.699: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:23.719: I/ActivityManager(1378): Start proc com.htc.android.mail for broadcast com.htc.android.mail/.AppMonitorReceiver: pid=26692 uid=9997 gids={3003, 1015} 
07-17 19:40:23.769: E/mode10(26672): PlayMarker fail, marker 'intro_to_up' not found in button.shortcut 
07-17 19:40:23.809: E/mode10(26672): Fail to load timeline from asset. 
07-17 19:40:23.819: E/mode10(26672): Timeline load failure 
07-17 19:40:23.829: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:23.849: D/Utilities(26672): createIconThumbnail # iconWidth: 72,iconHeight: 72,width: 72,height: 72 
07-17 19:40:23.929: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:23.939: I/RosieUtility(25755): disable self killer: mEnabled=1 
07-17 19:40:23.949: D/FxWidgetProvider(25755): row 81 
07-17 19:40:23.949: I/RosieUtility(25755): enable self killer: mEnabled=0 
07-17 19:40:23.979: D/StatusBarPolicy(1556): Network Type: 2 
07-17 19:40:24.009: W/dalvikvm(26692): Refusing to reopen boot DEX '/system/framework/com.htc.framework.jar' 
07-17 19:40:24.019: W/dalvikvm(26692): Refusing to reopen boot DEX '/system/framework/com.htc.android.pimlib.jar' 
07-17 19:40:24.019: W/dalvikvm(26692): Refusing to reopen boot DEX '/system/framework/com.htc.android.easopen.jar' 
07-17 19:40:24.019: D/FxScreen(26672): item count: 1 
07-17 19:40:24.079: E/mode10(26672): PlayMarker fail, marker 'intro_to_up' not found in button.shortcut 
07-17 19:40:24.129: E/mode10(26672): Fail to load timeline from asset. 
07-17 19:40:24.139: E/mode10(26672): Timeline load failure 
07-17 19:40:24.169: D/Utilities(26672): createIconThumbnail # iconWidth: 72,iconHeight: 72,width: 72,height: 72 
07-17 19:40:24.199: D/MessagingShortcut(25766): updateMsgShortcut, msg count> 0 
07-17 19:40:24.209: D/MessagingShortcut(25766): mPresentUnreadCount: 0 
07-17 19:40:24.209: D/MessagingShortcut(25766): setMsgShortcutDrawable> 0 
07-17 19:40:24.219: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:24.279: I/ActivityThread(26692): Pub com.htc.android.mail.attachmentprovider: com.htc.android.mail.provider.AttachmentProvider 
07-17 19:40:24.409: D/FxScreen(26672): item count: 2 
07-17 19:40:24.499: E/mode10(26672): PlayMarker fail, marker 'intro_to_up' not found in button.shortcut 
07-17 19:40:24.509: I/ActivityThread(26692): Pub mail: com.htc.android.mail.MailProvider 
07-17 19:40:24.549: E/mode10(26672): Fail to load timeline from asset. 
07-17 19:40:24.549: E/mode10(26672): Timeline load failure 
07-17 19:40:24.569: D/Utilities(26672): createIconThumbnail # iconWidth: 72,iconHeight: 72,width: 72,height: 72 
07-17 19:40:24.599: I/ActivityThread(26692): Pub com.htc.android.mail.MailCarousel: com.htc.android.mail.MailCarousel 
07-17 19:40:24.629: I/ActivityThread(26692): Pub htceas: com.htc.android.mail.eassvc.core.EASProvider 
07-17 19:40:24.650: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:24.650: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:24.650: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:24.660: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:24.670: D/AppMonitorReceiver(26692): 06021143 onReceive>Intent { act=com.htc.launcher.action.ACTION_ITEM_ADDED cmp=com.htc.android.mail/.AppMonitorReceiver (has extras) },#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.htc.android.mail/.MailListTab;end 
07-17 19:40:24.670: D/AppMonitorReceiver(26692): 06021143 update mail shortcut> 
07-17 19:40:24.700: D/MessagingShortcutReceiver(25766): keep hiding shortcut bubble 
07-17 19:40:24.710: D/AppMonitorReceiver(26692): 06021143 onReceive>Intent { act=com.htc.launcher.action.ACTION_ITEM_ADDED cmp=com.htc.android.mail/.AppMonitorReceiver (has extras) },#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.camera/.CameraEntry;end 
07-17 19:40:24.730: D/MessagingShortcutReceiver(25766): keep hiding shortcut bubble 
07-17 19:40:24.740: D/FxScreen(26672): item count: 1 
07-17 19:40:24.790: D/Database(26692): dbopen(): path = /data/data/com.htc.android.mail/databases/mail.db, flag = 6, file size = 76800 
07-17 19:40:24.840: I/Database(26692): sqlite returned: error code = 0, msg = Recovered 71 frames from WAL file /data/data/com.htc.android.mail/databases/mail.db-wal 
07-17 19:40:24.870: D/Database(26692): dbopen(): path = /data/data/com.htc.android.mail/databases/mail.db, mode: wal, disk free size: 485 M, handle: 0x353470 
07-17 19:40:25.000: D/dalvikvm(1378): GC_EXPLICIT freed 1482K, 34% free 11322K/17095K, external 2108K/2395K, paused 233ms 
07-17 19:40:25.020: D/CursorWindow(26692): Allocate Cursor Window, size = 4096 KB 
07-17 19:40:25.020: D/AppMonitorReceiver(26692): 06021143 onReceive>Intent { act=com.htc.launcher.action.ACTION_ITEM_ADDED cmp=com.htc.android.mail/.AppMonitorReceiver (has extras) },#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.browser/.BrowserActivity;end 
07-17 19:40:25.030: D/MessagingShortcut(25766): Send UNREAD_MESSAGE_COUNT broadcast: count=0 
07-17 19:40:25.030: E/mode10(26672): PlayMarker fail, marker 'intro_to_up' not found in button.shortcut 
07-17 19:40:25.060: E/mode10(26672): Fail to load timeline from asset. 
07-17 19:40:25.060: E/mode10(26672): Timeline load failure 
07-17 19:40:25.070: D/Utilities(26672): createIconThumbnail # iconWidth: 72,iconHeight: 72,width: 72,height: 72 
07-17 19:40:25.190: D/FxScreen(26672): item count: 3 
07-17 19:40:25.230: D/dalvikvm(26672): GetFieldID: unable to find field Ljava/util/Hashtable;.loadFactor:F 
07-17 19:40:25.230: D/MessagingShortcut(25766): updateMsgShortcut, msg count> 0 
07-17 19:40:25.250: D/MessagingShortcut(25766): mPresentUnreadCount: 0 
07-17 19:40:25.250: D/MessagingShortcut(25766): setMsgShortcutDrawable> 0 
07-17 19:40:25.620: D/dalvikvm(26692): GC_EXTERNAL_ALLOC freed 178K, 46% free 3017K/5511K, external 0K/0K, paused 595ms 
07-17 19:40:25.630: E/mode10(26672): Fail to load timeline from asset. 
07-17 19:40:25.630: E/mode10(26672): Timeline load failure 
07-17 19:40:25.721: I/FxListViewCollection(26672): FxListViewCollection is created with handle 17239736 
07-17 19:40:25.721: I/FxListViewCollection(26672): FxListViewCollection is created with handle 17072072 
07-17 19:40:25.721: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:25.741: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:26.311: D/FxScreen(26672): item count: 2 
07-17 19:40:26.311: E/mode10(26672): PlayMarker fail, marker 'intro_to_up' not found in button.shortcut 
07-17 19:40:26.391: E/mode10(26672): Fail to load timeline from asset. 
07-17 19:40:26.391: E/mode10(26672): Timeline load failure 
07-17 19:40:26.391: D/Utilities(26672): createIconThumbnail # iconWidth: 72,iconHeight: 72,width: 72,height: 72 
07-17 19:40:26.441: D/dalvikvm(26672): GC_CONCURRENT freed 1110K, 44% free 4408K/7815K, external 9207K/9227K, paused 13ms+9ms 
07-17 19:40:26.531: D/dalvikvm(26672): GC_EXTERNAL_ALLOC freed 58K, 45% free 4349K/7815K, external 9207K/9227K, paused 77ms 
07-17 19:40:26.621: D/dalvikvm(26672): GC_EXTERNAL_ALLOC freed 60K, 46% free 4288K/7815K, external 9227K/11275K, paused 69ms 
07-17 19:40:26.762: D/dalvikvm(26672): GC_EXTERNAL_ALLOC freed 23K, 46% free 4278K/7815K, external 9270K/11275K, paused 45ms 
07-17 19:40:26.792: D/FxScreen(26672): item count: 3 
07-17 19:40:26.842: E/mode10(26672): PlayMarker fail, marker 'intro_to_up' not found in button.shortcut 
07-17 19:40:26.892: E/mode10(26672): Fail to load timeline from asset. 
07-17 19:40:26.902: E/mode10(26672): Timeline load failure 
07-17 19:40:26.902: D/Utilities(26672): createIconThumbnail # iconWidth: 72,iconHeight: 72,width: 72,height: 72 
07-17 19:40:26.972: D/StatusBarPolicy(1556): Network Type: 2 
07-17 19:40:27.062: D/FxScreen(26672): item count: 4 
07-17 19:40:27.102: I/keystore(1271): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4 
07-17 19:40:27.122: E/mode10(26672): PlayMarker fail, marker 'intro_to_up' not found in button.shortcut 
07-17 19:40:27.162: E/mode10(26672): Fail to load timeline from asset. 
07-17 19:40:27.162: E/mode10(26672): Timeline load failure 
07-17 19:40:27.192: D/Utilities(26672): createIconThumbnail # iconWidth: 72,iconHeight: 72,width: 72,height: 72 
07-17 19:40:27.282: D/FxScreen(26672): item count: 5 
07-17 19:40:27.322: D/MessagingShortcut(25766): Send UNREAD_MESSAGE_COUNT broadcast: count=0 
07-17 19:40:27.322: E/mode10(26672): PlayMarker fail, marker 'intro_to_up' not found in button.shortcut 
07-17 19:40:27.352: E/mode10(26672): Fail to load timeline from asset. 
07-17 19:40:27.352: E/mode10(26672): Timeline load failure 
07-17 19:40:27.372: D/Utilities(26672): createIconThumbnail # iconWidth: 72,iconHeight: 72,width: 72,height: 72 
07-17 19:40:27.502: D/FxScreen(26672): item count: 4 
... 
+1

是否要重新啓動手機,或者當您單擊主頁按鈕時它正在重新啓動? – 2012-07-17 08:40:54

+1

在你的活動的onPause,onStop和onDestroy中放入一些日誌,並在重新啓動之前粘貼logcat發生在你的問題 – marmor 2012-07-17 08:42:12

+0

好問題,主題行說你的手機正在重新啓動,如果按主頁按鈕,但問題說你想切換關閉電話。最好的歧義。 – AAnkit 2012-07-17 09:13:44

回答

0

顯然,當按下 'HOME' 按鈕:只需點擊Home按鈕後

@Override 
protected void onPause() 
{ 
    Log.d(tag, "MYonPause is called"); 
    super.onPause(); 
} 

@Override 
protected void onStop() 
{ 
    Log.d(tag, "MYonStop is called"); 
    super.onStop(); 
} 

@Override 
protected void onDestroy() 
{ 
    Log.d(tag, "MYonDestroy is called"); 
    super.onDestroy(); 
} 

這裏是我的logcat該活動的onStop()方法被調用。您可以使用以下一段代碼來覆蓋(監視)它:

@Override 
protected void onStop() 
{ 
    super.onStop(); 
    Log.d(tag, "MYonStop is called"); 
    // insert here your instructions 
} 
相關問題