[android-developers] Re: detecting application loss of screen control
This is true. However, my application, which comprises many activities, is the one starting (most) activities not started by the HOME key, which can't be intercepted (googling android intercept home key will bring up multiple discussions of this). I would prefer not to have my app needlessly hammer the system every time it starts up one of its own activities. For now, I'm going with the almost-good-enough approach of updating its (zero, one, or more) app widgets when the root task closes (in its onPause(): isFinishing() is true, would also use isTaskRoot() if the task weren't always rooted by the same activity). I think it would be helpful if the API provided Activity.isTaskSwitching() and/or Activity.isApplicationSwitching() and maybe something to tell when being killed by the OS (e.g. for memory) for use in onPause() so that an application can tell that it's losing control. On Oct 9, 12:36 pm, RichardC richard.crit...@googlemail.com wrote: As I understand it you are right, you need to react to onPause in each activity (see also onSaveInstanceState()). The reason behind this is an end-user Task can comprise more than one Applicaton/Process with each Application consisting of more than one Activity. To give a made up example (which may not be possible with the actual Andoid code base): 1) End-user starts MyApp with MyActivity1 2) In MyActivity1 the end-user selects somethings which starts GoogleMaps / GoogleMapsActivity1 with some push pin data from MyApp. 3) End-user selects on of the push-pins that causes Google Maps to start MyActivity2 (in MyApp). So now we have MyApp MyActivity GoogleMaps GoogleMapsActivity1 MyApp MyActivity2 4) MyApp/MyActivity2 could now display a web page etc. Any Application/Process which is not the current forground Activity is a candidate to be killed by the OS if resources get tight. So each Activity that pauses needs to save its state so that when the end-user presses the back key it can restore itself and resume where it left off. -- RichardC On Oct 9, 6:22 pm, David Bernstein dbb.post...@gmail.com wrote: How can an application detect when it's lost control of the screen? The reason I ask is that my application has an appwidget whose visible state should be consistent with user actions within the application. In addition to the application exiting, I'd like to know when other applications take over the screen. Simply noticing in onPause() in the root activity isn't enough because the user can, for example, press the home key or receive a phone call. Noticing in onPause() in every single activity is overkill because the user will move between multiple activities in the same application. If this is documented or discussed already, I'll humbly accept an RTFM pointer, but I didn't find anything when I looked. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] detecting application loss of screen control
How can an application detect when it's lost control of the screen? The reason I ask is that my application has an appwidget whose visible state should be consistent with user actions within the application. In addition to the application exiting, I'd like to know when other applications take over the screen. Simply noticing in onPause() in the root activity isn't enough because the user can, for example, press the home key or receive a phone call. Noticing in onPause() in every single activity is overkill because the user will move between multiple activities in the same application. If this is documented or discussed already, I'll humbly accept an RTFM pointer, but I didn't find anything when I looked. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: ActivityNotFoundException on explicit class declared in manifest on G1, emulator OK
Found the problem due to problem with release build scripts. Diagnosis: pilot error. DOH! On Sep 30, 6:33 pm, David Bernstein dbb.post...@gmail.com wrote: I have some code that starts another activity based on a menu item selection: public boolean onOptionsItemSelected( MenuItem item ) { Log.d( TAG, onOptionsItemSelected(): entering... ); //... switch ( item.getItemId() ) { //... case MENU_REINIT: Log.d( TAG, onOptionsItemSelected(): MENU_REINIT ); startActivity( new Intent( this, InitWebAct.class ) ); break; case MENU_ACCT: Log.d( TAG, onOptionsItemSelected(): MENU_ACCT ); startActivity( new Intent( this, AcctAct.class ) ); break; //.. The MENU_REINIT and MENU_ACCT cases are coded identically. The REINIT case works everywhere. The MENU_ACCT case works in the emulator, but crashes on my real T-Mobile G1 running Android 1.5. Both activities are similarly declared in the Android manifest file: activity android:name=.AcctAct android:label=@string/c_acct /activity ... activity android:name=.InitWebAct android:label=@string/t_init /activity Trying to get that AcctAct activity started on the physical device crashes with an ActivityNotFoundException: ... 09-30 15:18:03.697 D/oma.ClubsAct( 3448): onOptionsItemSelected(): entering... 09-30 15:18:03.697 D/oma.ClubsAct( 3448): onOptionsItemSelected(): MENU_ACCT 09-30 15:18:03.697 I/ActivityManager( 56): Starting activity: Intent { comp={com.orgmob/com.orgmob.AcctAct} } 09-30 15:18:03.697 D/AndroidRuntime( 3448): Shutting down VM 09-30 15:18:03.697 W/dalvikvm( 3448): threadid=3: thread exiting with uncaught exception (group=0x4000fe70) 09-30 15:18:03.697 E/AndroidRuntime( 3448): Uncaught handler: thread main exiting due to uncaught exception 09-30 15:18:03.897 E/AndroidRuntime( 3448): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.orgmob/com.orgmob.AcctAct}; have you declared this activity in your AndroidManifest.xml? 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Instrumentation.checkStartActivityResult (Instrumentation.java:1480) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Instrumentation.execStartActivity(Instrumentation.java: 1454) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.startActivityForResult(Activity.java:2656) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.startActivity(Activity.java:2700) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.orgmob.ClubsAct.onOptionsItemSelected(ClubsAct.java:344) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.onOptionsItemSelected(Activity.java:2197) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.orgmob.ClubAct.onOptionsItemSelected(ClubAct.java:966) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.onMenuItemSelected(Activity.java:2085) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected (PhoneWindow.java:820) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java: 139) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:813) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.ExpandedMenuView.invokeItem (ExpandedMenuView.java:89) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.ExpandedMenuView.onItemClick (ExpandedMenuView.java:93) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.AdapterView.performItemClick(AdapterView.java:283) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.ListView.performItemClick(ListView.java:3132) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1620) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Handler.handleCallback(Handler.java:587) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Handler.dispatchMessage(Handler.java:92) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Looper.loop(Looper.java:123) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.ActivityThread.main(ActivityThread.java:3948) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at java.lang.reflect.Method.invokeNative(Native Method) 09-30 15:18:03.897 E/AndroidRuntime( 3448
[android-developers] Re: ActivityNotFoundException on explicit class declared in manifest on G1, emulator OK
Found the problem due to problem with release build scripts. Diagnosis: pilot error. DOH! On Sep 30, 6:33 pm, David Bernstein dbb.post...@gmail.com wrote: I have some code that starts another activity based on a menu item selection: public boolean onOptionsItemSelected( MenuItem item ) { Log.d( TAG, onOptionsItemSelected(): entering... ); //... switch ( item.getItemId() ) { //... case MENU_REINIT: Log.d( TAG, onOptionsItemSelected(): MENU_REINIT ); startActivity( new Intent( this, InitWebAct.class ) ); break; case MENU_ACCT: Log.d( TAG, onOptionsItemSelected(): MENU_ACCT ); startActivity( new Intent( this, AcctAct.class ) ); break; //.. The MENU_REINIT and MENU_ACCT cases are coded identically. The REINIT case works everywhere. The MENU_ACCT case works in the emulator, but crashes on my real T-Mobile G1 running Android 1.5. Both activities are similarly declared in the Android manifest file: activity android:name=.AcctAct android:label=@string/c_acct /activity ... activity android:name=.InitWebAct android:label=@string/t_init /activity Trying to get that AcctAct activity started on the physical device crashes with an ActivityNotFoundException: ... 09-30 15:18:03.697 D/oma.ClubsAct( 3448): onOptionsItemSelected(): entering... 09-30 15:18:03.697 D/oma.ClubsAct( 3448): onOptionsItemSelected(): MENU_ACCT 09-30 15:18:03.697 I/ActivityManager( 56): Starting activity: Intent { comp={com.orgmob/com.orgmob.AcctAct} } 09-30 15:18:03.697 D/AndroidRuntime( 3448): Shutting down VM 09-30 15:18:03.697 W/dalvikvm( 3448): threadid=3: thread exiting with uncaught exception (group=0x4000fe70) 09-30 15:18:03.697 E/AndroidRuntime( 3448): Uncaught handler: thread main exiting due to uncaught exception 09-30 15:18:03.897 E/AndroidRuntime( 3448): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.orgmob/com.orgmob.AcctAct}; have you declared this activity in your AndroidManifest.xml? 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Instrumentation.checkStartActivityResult (Instrumentation.java:1480) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Instrumentation.execStartActivity(Instrumentation.java: 1454) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.startActivityForResult(Activity.java:2656) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.startActivity(Activity.java:2700) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.orgmob.ClubsAct.onOptionsItemSelected(ClubsAct.java:344) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.onOptionsItemSelected(Activity.java:2197) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.orgmob.ClubAct.onOptionsItemSelected(ClubAct.java:966) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.onMenuItemSelected(Activity.java:2085) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected (PhoneWindow.java:820) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java: 139) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:813) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.ExpandedMenuView.invokeItem (ExpandedMenuView.java:89) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.ExpandedMenuView.onItemClick (ExpandedMenuView.java:93) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.AdapterView.performItemClick(AdapterView.java:283) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.ListView.performItemClick(ListView.java:3132) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1620) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Handler.handleCallback(Handler.java:587) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Handler.dispatchMessage(Handler.java:92) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Looper.loop(Looper.java:123) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.ActivityThread.main(ActivityThread.java:3948) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at java.lang.reflect.Method.invokeNative(Native Method) 09-30 15:18:03.897 E/AndroidRuntime( 3448
[android-developers] Re: ActivityNotFoundException on explicit class declared in manifest on G1, emulator OK
Found the problem due to problem with release build scripts. Diagnosis: pilot error. DOH! On Sep 30, 6:33 pm, David Bernstein dbb.post...@gmail.com wrote: I have some code that starts another activity based on a menu item selection: public boolean onOptionsItemSelected( MenuItem item ) { Log.d( TAG, onOptionsItemSelected(): entering... ); //... switch ( item.getItemId() ) { //... case MENU_REINIT: Log.d( TAG, onOptionsItemSelected(): MENU_REINIT ); startActivity( new Intent( this, InitWebAct.class ) ); break; case MENU_ACCT: Log.d( TAG, onOptionsItemSelected(): MENU_ACCT ); startActivity( new Intent( this, AcctAct.class ) ); break; //.. The MENU_REINIT and MENU_ACCT cases are coded identically. The REINIT case works everywhere. The MENU_ACCT case works in the emulator, but crashes on my real T-Mobile G1 running Android 1.5. Both activities are similarly declared in the Android manifest file: activity android:name=.AcctAct android:label=@string/c_acct /activity ... activity android:name=.InitWebAct android:label=@string/t_init /activity Trying to get that AcctAct activity started on the physical device crashes with an ActivityNotFoundException: ... 09-30 15:18:03.697 D/oma.ClubsAct( 3448): onOptionsItemSelected(): entering... 09-30 15:18:03.697 D/oma.ClubsAct( 3448): onOptionsItemSelected(): MENU_ACCT 09-30 15:18:03.697 I/ActivityManager( 56): Starting activity: Intent { comp={com.orgmob/com.orgmob.AcctAct} } 09-30 15:18:03.697 D/AndroidRuntime( 3448): Shutting down VM 09-30 15:18:03.697 W/dalvikvm( 3448): threadid=3: thread exiting with uncaught exception (group=0x4000fe70) 09-30 15:18:03.697 E/AndroidRuntime( 3448): Uncaught handler: thread main exiting due to uncaught exception 09-30 15:18:03.897 E/AndroidRuntime( 3448): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.orgmob/com.orgmob.AcctAct}; have you declared this activity in your AndroidManifest.xml? 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Instrumentation.checkStartActivityResult (Instrumentation.java:1480) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Instrumentation.execStartActivity(Instrumentation.java: 1454) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.startActivityForResult(Activity.java:2656) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.startActivity(Activity.java:2700) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.orgmob.ClubsAct.onOptionsItemSelected(ClubsAct.java:344) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.onOptionsItemSelected(Activity.java:2197) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.orgmob.ClubAct.onOptionsItemSelected(ClubAct.java:966) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.onMenuItemSelected(Activity.java:2085) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected (PhoneWindow.java:820) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java: 139) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:813) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.ExpandedMenuView.invokeItem (ExpandedMenuView.java:89) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.ExpandedMenuView.onItemClick (ExpandedMenuView.java:93) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.AdapterView.performItemClick(AdapterView.java:283) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.ListView.performItemClick(ListView.java:3132) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1620) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Handler.handleCallback(Handler.java:587) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Handler.dispatchMessage(Handler.java:92) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Looper.loop(Looper.java:123) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.ActivityThread.main(ActivityThread.java:3948) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at java.lang.reflect.Method.invokeNative(Native Method) 09-30 15:18:03.897 E/AndroidRuntime( 3448
[android-developers] ActivityNotFoundException on explicit class declared in manifest on G1, emulator OK
I have some code that starts another activity based on a menu item selection: public boolean onOptionsItemSelected( MenuItem item ) { Log.d( TAG, onOptionsItemSelected(): entering... ); //... switch ( item.getItemId() ) { //... case MENU_REINIT: Log.d( TAG, onOptionsItemSelected(): MENU_REINIT ); startActivity( new Intent( this, InitWebAct.class ) ); break; case MENU_ACCT: Log.d( TAG, onOptionsItemSelected(): MENU_ACCT ); startActivity( new Intent( this, AcctAct.class ) ); break; //.. The MENU_REINIT and MENU_ACCT cases are coded identically. The REINIT case works everywhere. The MENU_ACCT case works in the emulator, but crashes on my real T-Mobile G1 running Android 1.5. Both activities are similarly declared in the Android manifest file: activity android:name=.AcctAct android:label=@string/c_acct /activity ... activity android:name=.InitWebAct android:label=@string/t_init /activity Trying to get that AcctAct activity started on the physical device crashes with an ActivityNotFoundException: ... 09-30 15:18:03.697 D/oma.ClubsAct( 3448): onOptionsItemSelected(): entering... 09-30 15:18:03.697 D/oma.ClubsAct( 3448): onOptionsItemSelected(): MENU_ACCT 09-30 15:18:03.697 I/ActivityManager( 56): Starting activity: Intent { comp={com.orgmob/com.orgmob.AcctAct} } 09-30 15:18:03.697 D/AndroidRuntime( 3448): Shutting down VM 09-30 15:18:03.697 W/dalvikvm( 3448): threadid=3: thread exiting with uncaught exception (group=0x4000fe70) 09-30 15:18:03.697 E/AndroidRuntime( 3448): Uncaught handler: thread main exiting due to uncaught exception 09-30 15:18:03.897 E/AndroidRuntime( 3448): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.orgmob/com.orgmob.AcctAct}; have you declared this activity in your AndroidManifest.xml? 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Instrumentation.checkStartActivityResult (Instrumentation.java:1480) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Instrumentation.execStartActivity(Instrumentation.java: 1454) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.startActivityForResult(Activity.java:2656) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.startActivity(Activity.java:2700) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.orgmob.ClubsAct.onOptionsItemSelected(ClubsAct.java:344) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.onOptionsItemSelected(Activity.java:2197) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.orgmob.ClubAct.onOptionsItemSelected(ClubAct.java:966) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.Activity.onMenuItemSelected(Activity.java:2085) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected (PhoneWindow.java:820) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java: 139) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:813) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.ExpandedMenuView.invokeItem (ExpandedMenuView.java:89) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.view.menu.ExpandedMenuView.onItemClick (ExpandedMenuView.java:93) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.AdapterView.performItemClick(AdapterView.java:283) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.ListView.performItemClick(ListView.java:3132) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1620) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Handler.handleCallback(Handler.java:587) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Handler.dispatchMessage(Handler.java:92) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.os.Looper.loop(Looper.java:123) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at android.app.ActivityThread.main(ActivityThread.java:3948) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at java.lang.reflect.Method.invokeNative(Native Method) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at java.lang.reflect.Method.invoke(Method.java:521) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:782) 09-30 15:18:03.897 E/AndroidRuntime( 3448): at