how do i make accelerometer run in background

Put your problem here if it does not fit any of the other categories.

how do i make accelerometer run in background

Postby darko1002001 » Sat Jul 03, 2010 9:33 pm

hi.

here is my question. i need a way to make the accelerometer collect data even if we exit the application until i stop it manually after a longer period of time (1-2 hours maybe). now i have it set up in an activity and it doesn't work if the phone locks or i exit the app.
what is the best way to do this? maybe if u can suggest some examples.

tnx.
darko1002001
Junior Developer
Junior Developer
 
Posts: 20
Joined: Sat Jun 26, 2010 12:52 am

Top

Re: how do i make accelerometer run in background

Postby anarche » Sun Jul 04, 2010 3:58 am

And don't rely on it still running, since the OS may scratch its process if its running out of resources.
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: how do i make accelerometer run in background

Postby blundell » Sun Jul 04, 2010 10:26 am

Before it is scrapped you can do some stuff though can't you. I.e. inform the user or start an activity or somethin in onLowMemory()?
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: how do i make accelerometer run in background

Postby anarche » Sun Jul 04, 2010 10:33 am

Yep.

Its still not guaranteed, tho'. If somebody loads a bloated app or something the OS may just kill processes; without calls to onStop, onDestroy.

I'm wondering if their could be a situation where onLowMemory() is skipped? say the OS thread is killing background processes -> switch to app thread that sits in a loop instatiating objects -> emergency memory runout -> OS starts killing foreground threads to make room for paging...

This is an extreme and unlikely situation tho'.
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: how do i make accelerometer run in background

Postby darko1002001 » Tue Jul 06, 2010 6:45 pm

well doing that onlowMemory() seems a good idea, maybe set an alert or something so that the user knows if it is shutting down. but will running simple apps in the range of call dialing, text messaging etc.. drain the memory so my process shuts down? as far i have learned it will shut down only if the users starts something massive, a game maybe..?? is that correct?
darko1002001
Junior Developer
Junior Developer
 
Posts: 20
Joined: Sat Jun 26, 2010 12:52 am

Top

Re: how do i make accelerometer run in background

Postby blundell » Tue Jul 06, 2010 6:56 pm

Correct
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: how do i make accelerometer run in background

Postby darko1002001 » Thu Jul 08, 2010 11:21 pm

ok just one more problem i encountered. i want to transmit from the service to activity, im my case i want to change the value in a textView in the activity every second based on the changes made in the service. (i have a counter running in the service and i want to place its values in a textView in the activitiy realtime)
i already tried doing this with using shared preferences and a sharedpreferences listener, but it doesnt work like its supposed to :(, the app blocks down and i dont get the values all the time, i get them for example 1 then 7 then 14 ....

what is the way of doing this?
darko1002001
Junior Developer
Junior Developer
 
Posts: 20
Joined: Sat Jun 26, 2010 12:52 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 13 guests