Is it possible to use the accelerometer in a background service?

by John Smith » Thu, 10 Sep 2009 01:05:47 GMT


Sponsored Links
 It seems trivial to use GPS in a background service, but how can you
do the same with the accelerometer?

Everything I've tried seems to require a context, but a background
service doesn't have a context?

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



Is it possible to use the accelerometer in a background service?

by Mike Collins » Thu, 10 Sep 2009 01:43:01 GMT


 my service uses "getBaseContext()", seems to work just fine.  Don't
use it for
GPS but we do use it for many other things.

  mike




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


Sponsored Links


Is it possible to use the accelerometer in a background service?

by dadical » Thu, 10 Sep 2009 02:46:05 GMT


 I register a listener to orientation sensor from within a background
service with no trouble.  Perhaps the following code may help.  These
methods are called from my service's onCreate and onDestroy methods:

        private void startMonitoring(){
                SensorManager lMgr = (SensorManager) getSystemService
(Context.SENSOR_SERVICE);

                try{
                        lMgr.unregisterListener(this);
                } catch(Exception e){
                        Log.d(ScreeblService.class.getSimpleName(), 
e.toString());
                }

                List<Sensor> lSensorList = lMgr.getSensorList
(Sensor.TYPE_ORIENTATION);
                if(lSensorList == null || lSensorList.size() == 0){
                        throw new RuntimeException("Orientation sensor not 
available!");
                }

                                // assumes that this class implements
SensorEventListener
                lMgr.registerListener( this, lSensorList.get(0),
SensorManager.SENSOR_DELAY_NORMAL );

        }

        private void stopMonitoring(){
                SensorManager lMgr = (SensorManager) getSystemService
(Context.SENSOR_SERVICE);

                try{
                        lMgr.unregisterListener(this);
                } catch(Exception e){
                        Log.d(ScreeblService.class.getSimpleName(), 
e.toString());
                }

        }





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



Other Threads

1. AndAppStore & Archos (Was Is your Android app on Archos Market ?)

[Moving this to -discuss as it's was off topic for -developers]


 > Charbax wrote on Mon, 9 Nov 2009 01:04:57 -0800 (PST)
 >
 > Slander and disparage doesn't have to use f-words and s-words.

Slander has a specific meaning, and as for disparage, well, you can  
call my opinions disparaging of Archos if you think they are, that's  
your view.
 > alsutton has coordinated constant Archos bashing on the archosfans
 > forum since September 2nd until about October 15th when he first
 > announced he was seeking legal advice.

First off you need to get your facts right. We announced we were  
seeking legal advice on the 16th of October and my last post was made  
on the 28th of October where I clearly stated my reasons for stopping  
posting were due to your continual attempts to mislead users, which,  
when I asked you to back them up, you responded with personal insults  
directed at me.

Secondly, as I've told you before, I wanted to help users determine  
what was an Archos issue and what was an Android issue so they  
wouldn't try the A5 and walk away thinking Android was at fault.  
Archos did some heavy customisations to Android (from software buttons  
on the UI through to running a separate media framework on the same  
device), and hence the possibility for confusion.

You only need to look on your own sites forums to see the problems  
users were having, and it's separating things like the random crashes,  
problems going into suspend, time to acquire a GPS lock, which are  
most likely issues specific to the Archos, from things like no WPA2  
Enterprise support and problems with hidden SSIDs, which are generic  
Android issues and are registered in b.android.com, so that users  
don't think that if they buy an Android device from another  
manufacturer they're going to see all the same problems.

 > All things from:
 > - Recommending that people not buy the Archos 5 Internet Tablet in   
countless posts

Which is something numerous other people and reviews have said in  
relation to consumers buying it.

 > - Advertising for alternatives to Archos 5 Internet Tablet in   
countless posts

You have a forum called "Competitors" which is specifically for this  
reason, so what exactly is wrong with that?

 > - Claiming to have inside knowledge from Google engineers that  
Google Marketplace and Google Apps would never be available on Archos  
5  Internet Tablet in countless posts

Would you like to point at a post where I claim to have "inside  
knowledge from Google engineers"?. I don't remember ever claiming  
that, but what I do remeber is pointing out that the A5 lacks many of  
the hardware features needed for a Google Experience device, and this  
is something T3 published in their review at 
http://www.t3.com/reviews/ipod-and-mp3-players/all-mp3-players/archos-android-5-internet-tablet-review
 
  (third paragraph after the set of 4 links)

 > - Plenty of other trolling posting controversial, inflammatory,  
irrelevant and off-topic messages

That may be your view of them, other people had different views, and  
given that most of your responses to my posts were generally littered  
with insults aimed at me or a refusal to provide evidence for you  
claims I hardly think you're in a good position.
 > I'm looking forward to see the emails. I am sure alsutton was asking
 > an unreasonably large payment to be the exclusive marketplace on the
 > device. Probably his dream, to finally have an opportunity make some
 > money on his marketplace project.

Once Archos release them from being covered by the NDA then I will be  
happy to supply them to you.

In terms of the money involved, well, do you really think Archos would  
have supplied us with a contract and a commitment to countersign it if  
we were just looking for a huge payout?

Al.






- Hide quoted text -

 > On Nov 7, 11:25 pm, "Fred Grott(Android 
 > Expert,http://mobilebytes.wordpress.com 
)"


 > > Charbox your slander definition seems to be somewhat unique and
 > > different.

 > Agreed. His coordinate system for slander and disparage could use  
some
 > calibration, it seems. 

--

2. hapus bar-nya lockscreen

buat yang pake hero based rom .... ada yang tahu cara hapus bar di
lockscreen ?? jadi pas lockscreen, layar total sama wallpaper-nya aja ...

-- 
Arianto C Nugroho

--~--~---------~--~----~------------~-------~--~----~
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:

Click  

3. Media Recorder - videocamera.java

4. Eclipse version

5. How to store Images in sqlite database using android? & How to retrieve images from sqlite database

6. listening on TCP sockets in android emulator problem

7. writing firewall applications for Android