DO NOT DO THIS!!!

Especially since there is a public API for this:

http://developer.android.com/reference/android/telephony/PhoneStateListener.html

We've been through the whole "don't use private APIs" stuff enough times, so
I'll just note:

1. This is not "a bit of an advanced topic," this is outright hacking a
fragile kludge.
2. Please do not recommend that people do this kind of stuff at least
without the relevant caveats that it is not a supported thing to do and they
can expect their app to break.
3. Just because you get something to run on the current G1 today does not
mean it is the right thing to do.

On Thu, Mar 12, 2009 at 3:28 PM, <mark.ka...@gmail.com> wrote:

>
>
>   This can be done, but it is a bit of an advanced topic. You'll need
> to use an internal class which is
> com.android.internal.telephony.PhoneStateIntentReceiver
>
> Grab this package, the .class files  from the cupcake source tree
> repository , (doesn't ship with the SDK) and add the classes to you're
> class path, and include in the /libs directory, or package them into
> your existent android.jar file.
>
> Code to get the signal strength is as follows:
>
> import com.android.internal.telephony.PhoneStateIntentReceiver;
> private static final int EVENT_SIGNAL_STRENGTH_CHANGED = 200;
> ..
> /// first initialize the PhoneStateIntentReceiver (assumes you're
> inside a class that extends Context)
>
> void initPhoneStateReciever()
>    {
>       phoneStateReciever = new  PhoneStateIntentReceiver(this, new
> Handler( getMainLooper()));
>       phoneStateReciever.notifySignalStrength
> (EVENT_SIGNAL_STRENGTH_CHANGED);
>       phoneStateReciever.registerIntent();
>    }
>
> //to get the signal strength, use this method, or something similar
>
> void updateSignalStrength()
>   {
>           int signalDbm = phoneStateReciever.getSignalStrengthDbm();
>           int signalAsu = phoneStateReciever.getSignalStrength();
>          System.out.println("Time: "+System.currentTimeMillis()+"
> Signal Strength DB: "+signalDbm+" strength Asu: "+signalAsu);
>   }
>
>
> The use of internal classes is not officially supported, and you'll
> need to grab the .class files from the source repo, but I do actually
> have code that implements and is tested on the G1. Refer to other
> threads on options for getting the code and setting up your
> development environment to use internal classes. Good luck!
>
>                                   Mark
>
>
>
> On Mar 11, 7:49 am, Shrikant Agrawal <shrikant...@gmail.com> wrote:
> > Hi
> >
> > I want to find the network signal strength for my app.
> > But I cant find the api for it.
> >
> > Do anybody know how to find the signal strength of the phone?
> >
> > Thanks
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to