[android-developers] Getting Current Signal Strength

2010-01-14 Thread dolsen
I am trying to figure out how to get the current signal strength of
the Android 2.1 device. So far I can only find access to the
SignalStrength object if I am listening for a change. I don't want to
have to wait for the strength to change in order to see what the
strength is. Can someone show me how this can be done?
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: How to get service state?

2010-01-13 Thread dolsen
I have the same problem. I want to get the state of the phone when my
app starts. I am also new to Android so a code snippet would be nice.

On Jan 6, 5:29 am, Coby timur.dyusseba...@gmail.com wrote:
 Hi!

 I'm trying to get current service state of my phone (IN_SERVICE,
 OUT_OF_SERVICE, EMERGENCY_ONLY, POWER_OFF). It can be easily fetched
 with getState() method of ServiceState when a onServiceStateChanged
 (ServiceState serviceState) callback is invoked:

 public class ServiceStateListener extends PhoneStateListener{
 @Override
             public void onServiceStateChanged(ServiceState serviceState) {
                 switch(serviceState.getState()){
                                 case ServiceState.STATE_IN_SERVICE:
                                         Log.i(Listener, In Service);
                         break;
                                 case ServiceState.STATE_EMERGENCY_ONLY:
                                         Log.i(Listener, Emergency);
                                         break;
                                 case ServiceState.STATE_OUT_OF_SERVICE:
                                         Log.i(Listener, Out Of Service);
                                         break;
                                 case ServiceState.STATE_POWER_OFF:
                                         Log.i(Listener, Phone Off);
                                         break;
                         }
         }

 But if you explicitly create a ServiceState object and try to get it's
 state. It's always Out Of Service (returns 1), no matter what state
 your phone is in right now:

 @Override
 public void onCreate() {
         ServiceState serviceState = new ServiceState();
         Log.i(onCreate, Integer.toString(serviceState.getState()));

 }

 I don't have much experience with Android. Any help is appreciated.
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en