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. What widget frameworks are available on Android platform?

Folks,

I searched a lot and could not find answer to this.  I am hoping to
post it here on the developer group with a hope that fellow developers
can chime in.

Thanks

I am trying to find which mobile widget frameworks are available on
the android platform.  The main reason i am looking for these
frameworks is to develop code that is portable across different
devices.  I know of a few frameworks out there, like Yahoo blueprint,
opera mini and streamezzo.  Some of these are like the yahoo one is
not available on android.

My question is simple:

1. What frameworks are you aware of that are available on android
platform?

Thanks!

--~--~---------~--~----~------------~-------~--~----~

2. content://sms/sent Read SMS

Hi, I'm having a problem reading the SMS messages from the device.
When acquiring a content provider for the URI content://sms/inbox -
everything is fine, I read the "person" column to find the foreign key
into the people table and I can ultimately reach the contact and their
name.

However, I also want to traverse the sent messages too. When reading
from content://sms/sent, the person field always appears to be 0. Is
this the correct field to be reading to locate the recipient data for
the sent message? If so - why is it always 0.

All my testing has been done in the emulator and I've created 3
contacts. I've sent messages to those contacts from the emulator in
the normal manner you'd send a message.

Just to reiterate, I can see the 4 sent messages and read the
associated body text. My problem is that I can't seem to read the
"person" ID and hence I can't work out who the recipient is.

Any help would be greatly appreciated.

Many thanks,

Martin.

--~--~---------~--~----~------------~-------~--~----~

3. Plugin download site gives 404

4. How to add SMS to inbox in android programmatically?

5. Application to determine location in home -- upstairs or downstairs

6. How does an Activity being drawn

7. StartActivity() in BroadcastReceiver