Close all activities and services for an app?

by Mark Murphy » Thu, 15 Jul 2010 01:30:01 GMT


Sponsored Links
 


Do not do this.


Call finish() in your activity if they decline the terms of service.


Please do not do this in production code.


Fix your launch activity.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
Available!

--



Close all activities and services for an app?

by Boozel » Thu, 15 Jul 2010 01:40:36 GMT


 finish() doesnt stop the service or any other activities that are
running, any way to stop all things in this package?
How do I "Fix my launch activity"?







--


Sponsored Links


Close all activities and services for an app?

by Mark Murphy » Thu, 15 Jul 2010 01:52:14 GMT


 


I told you not to build your app this way. You did not listen. I will
say it again: your concept of having a service that opens a terms of
service activity is a mistake. Do not build your app this way.

You can call stopService() to stop your service. Redesign your
application such that there are no other activities open. Then,
finish() on your terms-of-service activity will be all that is needed.


How should I know? Android does not magically cause "the launch
activity automatically starts aggin" if it was already destroyed
(finish(), BACK button, etc.). Something is calling startActivity() to
start it up again. LogCat may give you some clues.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
Available!

--



Close all activities and services for an app?

by Nathan » Thu, 15 Jul 2010 02:14:32 GMT


 


Don't start all that other stuff before they accept the terms of
service?

Nathan

--



Close all activities and services for an app?

by Boozel » Thu, 15 Jul 2010 04:48:43 GMT


 ou were correct, i tried to do it the way you suggested but ran into
a problem so tried the old way as a work around. It just caused more
issues though. i've re written it so the activity starts the service
and have got it all working.
Thanks,

The only issue i have is that when i have the second activity on the
screen (terms and conditions) and i kill it on the emulator via the
task list it restarts the first activity which restarts the second.
any ideas why? here is my log

07-14 22:43:20.885: INFO/ActivityManager(102): Starting activity:
Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x10200000
cmp=com.example.test/.bbClient }
07-14 22:43:21.465: INFO/ARMAssembler(102): generated
scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at
[0x3894f0:0x3895fc] in 2346763 ns
07-14 22:43:22.175: INFO/ActivityManager(102): Start proc
com.example.test for activity com.example.test/.bbClient: pid=447
uid=10028 gids={3003, 1015}
07-14 22:43:23.086: DEBUG/ddm-heap(447): Got feature list request
07-14 22:43:23.595: INFO/ARMAssembler(102): generated
scanline__00000177:03515104_00000001_00000000 [ 73 ipp] (95 ins) at
[0x333200:0x33337c] in 1673319 ns
07-14 22:43:24.315: INFO/ActivityManager(102): Starting activity:
Intent { cmp=com.example.test/.TsandCs }
07-14 22:43:26.535: INFO/ActivityManager(102): Displayed activity
com.example.test/.TsandCs: 1936 ms (total 5325 ms)
07-14 22:43:26.916: INFO/ARMAssembler(102): generated
scanline__00000077:03545404_00000A04_00000000 [ 29 ipp] (51 ins) at
[0x3335c0:0x33368c] in 5497347 ns
07-14 22:43:31.506: DEBUG/dalvikvm(447): Calling exit(1)
07-14 22:43:31.635: DEBUG/Zygote(30): Process 447 exited cleanly (1)
07-14 22:43:31.685: INFO/ActivityManager(102): Process
com.example.test (pid 447) has died.
07-14 22:43:31.697: INFO/WindowManager(102): WIN DEATH:
Window{43c3d248 com.example.test/com.example.test.TsandCs
paused=false}
07-14 22:43:31.785: INFO/WindowManager(102): WIN DEATH:
Window{43c15e10 com.example.test/com.example.test.bbClient
paused=false}
07-14 22:43:32.075: INFO/ActivityManager(102): Start proc
com.example.test for activity com.example.test/.bbClient: pid=455
uid=10028 gids={3003, 1015}
07-14 22:43:32.805: DEBUG/ddm-heap(455): Got feature list request
07-14 22:43:33.265: INFO/UsageStats(102): Unexpected resume of
com.example.test while already resumed in com.example.test
07-14 22:43:33.875: INFO/ActivityManager(102): Starting activity:
Intent { cmp=com.example.test/.TsandCs }
07-14 22:43:35.025: WARN/InputManagerService(102): Got RemoteException
sending setActive(false) notification to pid 447 uid 10028
07-14 22:43:35.625: INFO/ActivityManager(102): Displayed activity
com.example.test/.TsandCs: 1388 ms (total 3802 ms)

and thanks again i really appreciate all the help.

On Jul 14, 7:47pm, Mark Murphy <mmur...@commonsware.com> wrote:

--



Close all activities and services for an app?

by Mark Murphy » Thu, 15 Jul 2010 04:54:04 GMT


 


What do you mean by "kill it on the emulator via the task list"? There
is no "task list" on the emulator. There's the process list in DDMS,
but terminating a process should not trigger an activity to be
started. There's the "most recent tasks" list (long press on HOME),
but that does not kill anything, but rather brings that task to the
foreground.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
Available!

--



Close all activities and services for an app?

by Boozel » Thu, 15 Jul 2010 05:00:12 GMT


 sorry i mean via the process list on DDMS.






--



Close all activities and services for an app?

by Mark Murphy » Thu, 15 Jul 2010 05:03:46 GMT


 


Like I said, I have no idea why/how terminating a process in DDMS
would trigger the launching of an activity. You have me stumped.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
Available!

--



Other Threads

1. Garbled extracted XML resources

Hello,
When I extract a XML file from res/layout in an APK file it is garbled
up. How can I fix this?
Thanks,
Isaac
--~--~---------~--~----~------------~-------~--~----~

2. How to wait for an activity under test to launch?

Hi,

I am writing tests using the Android test framework
"ActivityInstrumentationTestCase2". In this after launching an
activity I want to wait till it gets fully launched and then proceed.

I tried these but none of them work.
1. getInstrumentation().waitForIdleSync();
2. while (!getActivity().isFinishing())
          Thread.sleep(100);


As a result my test code and the application under test are not in
sync.

Thanks
Yasser
--~--~---------~--~----~------------~-------~--~----~

3. Canvas.drawBitmapMesh()

4. Anyway one have experience with INJECT_EVENT ?

5. QVGA screen resolution applications

6. Trying to invoke Google Gears from Android browser

7. CameraPreview: Out of memory