This is the way you get the signal strength.  The status bar uses the exact
same information to show its bars.

On Mon, Apr 6, 2009 at 1:18 PM, Matthew <[email protected]> wrote:

>
> Hello,
>
> I am new to this Group.
>
> Thank you for your recommendation to avoid using unsupported
> techniques.
>
> I am trying to obtain the signal strength seen by the G1 phone.
>
> As you had referred to, I have implemented a PhoneStateListener and
> onSignalStrengthChanged (int asu).
>
> It looks like I am seeing only a few  returned asu values (e.g., 2, 6,
> 12 and 25).
>
> I believe that the mapping of asu to dBm is as follows: -113dBm +
> 2*asu. Therefore, it looks like the G1 phone is reporting dBm values
> of -109, -101, -89 and -63.
>
> Also, I see that the signal strength icon used by the G1 has four bars
> (I am assuming that each bar corresponds to one of the 2, 6, 12 and 25
> asu values).
>
> Question: do you know if there is a supported way to obtain signal
> strength (either as an asu measure or a direct dBm measure) with a
> higher level
> of granularity (that is, for example, in single asu steps or single
> dBm steps)?
>
> Thank you in advance for any help or comments.
>
>
> On Mar 31, 3:40 am, Dianne Hackborn <[email protected]> wrote:
> > DO NOT DO THIS!!!
> >
> > Especially since there is a public API for this:
> >
> > http://developer.android.com/reference/android/telephony/PhoneStateLi...
> >
> > 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, <[email protected]> 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 <[email protected]> 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
> > [email protected]
> >
> > 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.- Hide quoted text -
> >
> > - Show quoted text -
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to