Hi Dan. Did you ever find an answer for this? On Monday, January 28, 2013 4:53:23 PM UTC+3, Dan wrote: > > I saw: > > http://developer.android.com/reference/android/telephony/CellInfo.html > > and thought that having the signal strength tower ID and in use and > neighboring > towers all in one callback would be nice to have. I wrote a test program > to see > if I could get this CellInfoGsm on a Galaxy Nexus or Nexus 4. Snippet of > test > code follows: > > > @Override > public void onCreate() { > // Notification to not get killed > Log.d("CellInfoTest","Service onCreate"); > mNotification = buildNotification(); > startForeground(5,mNotification); > > ((NotificationManager)getSystemService(NOTIFICATION_SERVICE)).notify(5,mNotification); > mListener = new PhoneStateListener() { > public void onCellInfoChanged(List<CellInfo> c) { > Log.d("CellInfoTest","onCellInfoChanged > called"); > dumpCellInfoList(c); > } > public void onCellLocationChanged(CellLocation c) { > > Log.d("CellInfoTest","onCellLocationChanged called"); > > dumpCellLocation(c); > } > }; > myTm = > (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); > > } > > private void dumpCellInfoList(List<CellInfo> c) { > try { > for (int i = 0; i < c.size(); i++) { > > Log.d("CellInfoTest","dumpInfoLocation:"+c.get(i).toString()); > } > } catch (java.lang.NullPointerException e) { > Log.d("CellInfoTest","Null pointer for CellInfo"); > } > } > > private void dumpCellLocation(CellLocation c) { > try { > > Log.d("CellInfoTest","dumpCellLocation:"+c.toString()); > } catch (java.lang.NullPointerException e) { > Log.d("CellInfoTest","Null pointer for > CellLocation"); > } > } > > @Override > public int onStartCommand(Intent i, int flags, int startid){ > Log.d("CellInfoTest","Service onStartCommand"); > myTm.listen(mListener, > PhoneStateListener.LISTEN_CELL_INFO + > PhoneStateListener.LISTEN_CELL_LOCATION); > return START_STICKY; > } > > I've also included > > <uses-sdk android:minSdkVersion="17" /> > <uses-permission > android:name="android.permission.ACCESS_COARSE_LOCATION"/> > > in the manifest to be sure I was on an updated phone that supported the > API and could see > the cell location information. I gathered the adb logcat output and > toggled the airplane mode > a few times to see what got called back. I'm seeing: > > 01-25 19:04:31.516 D/CellInfoTest( 7999): Starting service > 01-25 19:04:31.526 D/CellInfoTest( 7999): Service onCreate > 01-25 19:04:31.526 D/CellInfoTest( 7999): Service onStartCommand > 01-25 19:04:31.536 D/CellInfoTest( 7999): onCellLocationChanged called > 01-25 19:04:31.536 D/CellInfoTest( 7999): > dumpCellLocation:[10989,194036662,418] > 01-25 19:04:31.536 D/CellInfoTest( 7999): onCellInfoChanged called > 01-25 19:04:31.536 D/CellInfoTest( 7999): Null pointer for CellInfo > 01-25 19:04:58.935 D/CellInfoTest( 7999): onCellLocationChanged called > 01-25 19:04:58.935 D/CellInfoTest( 7999): dumpCellLocation:[10989,-1,418] > 01-25 19:04:59.826 D/CellInfoTest( 7999): onCellLocationChanged called > 01-25 19:04:59.826 D/CellInfoTest( 7999): dumpCellLocation:[-1,-1,-1] > 01-25 19:04:59.956 D/CellInfoTest( 7999): onCellLocationChanged called > 01-25 19:04:59.966 D/CellInfoTest( 7999): dumpCellLocation:[-1,-1,0] > 01-25 19:05:00.857 D/CellInfoTest( 7999): onCellLocationChanged called > 01-25 19:05:00.857 D/CellInfoTest( 7999): > dumpCellLocation:[10989,194036662,418] > > which looks like as soon as I register I get a callback, but the CellInfo > is null (which > I think is very odd, as it should at least contain the location/strength > of the cell that > is currently connected and dumped by dumpCellLocation) each of the > callbacks that > follow happen with the airplane mode toggle an only for > onCellLocationChanged. > > My questions are: > > Is there a flaw in my code that I am missing? > Is there a permission that I need to get the onCellInfoChanged callback to > happen? > If my code looks good, who do I look to to ask why the Galaxy Nexus and > Nexus 4 > both fail to make the callbacks (is there a CTS case update that needs to > happen, > or should I file a bug against the android code?) > > Dan S. > >
-- 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 --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

