I want to bring my application to front if the cell phone has a speed more than 70 km /hour. It already runs in background as a service. Any help will be highly appreciated.
Asked
Active
Viewed 304 times
1 Answers
2
You can follow the above steps:
In the service you will have to detect the speed of the phone using accelerometer. See Using accelerometer to calculate speeds and there are many other questions to answer this part.
When you detect the speed going above 70 km/hr, open the home activity of the app using
Intent
. See android start activity from service
You may have to include a check that if the activity has been started once, when the speed went over 70km/hr, it should be started again and again for the same ocassion.
This is my 2 cents for your problem. Hope it helps.

Community
- 1
- 1

Shobhit Puri
- 25,769
- 11
- 95
- 124
-
Thanks a lot it worked.... Though i would love if you tell me how to go to any other xml instead of home activity directly. Thanks again. – user2683871 Dec 27 '13 at 05:32
-
Just start that particular activity instead of Home one. – Shobhit Puri Dec 27 '13 at 05:51
-
tried it. but does not work for any other activity else than mainActivity :( – user2683871 Dec 27 '13 at 06:19