1

There seems to be a lot of controversy about how to stop applications in Android, so I'll explain what I'm trying to do and why in hopes that I can receive some guidance on how to properly implement the functionality I'm looking for.

I got tired of plugging my phone into power when I get into the car, connecting the headphones, turning BT on, turning WiFi off, and then launching "Car Home" because my dock doesn't do so automatically - it's just a piece of plastic mounted to the dash.

So my application automatically does these things when I connect power - and when I disconnect power, it turns BT off and WiFi back on, but unfortunately, Car Home is still running.

I want to automate the entire process, so I never have to launch (or shut down) Car Home, and make getting in and out of the car a little less frustrating.

I know Froyo introduces ActivityManager's killBackgroundProcesses method, but this doesn't seem to work for me. It does seem to be focused around background processes, but what I've read online seems people want to use it to stop foreground applications.

I've also tried restartPackage from Eclair unsuccessfully, so I'm looking for advice.

What is the best way for me to tell the "Car Home" application to stop specifically because power is disconnected and I'm getting out of the car, without me having to navigate to it's home page and click "Exit"?

rekire
  • 47,260
  • 30
  • 167
  • 264
Justin
  • 11
  • 2
  • This is a pretty unique use case. You'll probably have to just kill the process like a task killer. – Falmarri Nov 19 '10 at 23:35
  • Is that the best solution I can implement? If I am to implement a solution like a task killer, what're they doing? I'm under the impression task killers are using undocumented methods, which isn't really the route I'd like to go to solve my problem, if possible. – Justin Nov 19 '10 at 23:53

1 Answers1

0

Have you seen UiModeManager?

This class provides access to the system uimode services. These services allow applications to control UI modes of the device. It provides functionality to disable the car mode and it gives access to the night mode settings.

adamp
  • 28,862
  • 9
  • 81
  • 69