Android - Access Cell Phone details (Cell-Id, LAC, Signal Strength)
Here is the screen shot
|
Next Step(s)!
Need to figure out how to use cell-id/lac information to get a lat/long for the phone location! Please drop me a note or add comments here if you have an idea on how to do it. Thanks.
Source
package org.apache;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.telephony.PhoneStateIntentReceiver;
import android.telephony.ServiceState;
import android.util.Log;
import android.widget.EditText;
public class LocateMe extends Activity {
private PhoneStateIntentReceiver mPhoneStateReceiver;
private EditText mEditLac;
private EditText mEditCid;
private EditText mEditSignal;
private static final int MY_NOTIFICATION_ID = 0x100;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
mPhoneStateReceiver = new PhoneStateIntentReceiver(this, new ServiceStateHandler());
mPhoneStateReceiver.notifyServiceState(MY_NOTIFICATION_ID);
mPhoneStateReceiver.notifyPhoneCallState(MY_NOTIFICATION_ID);
mPhoneStateReceiver.notifySignalStrength(MY_NOTIFICATION_ID);
mPhoneStateReceiver.registerIntent();
mEditLac = (EditText) findViewById(R.id.lac);
mEditCid = (EditText) findViewById(R.id.cell_id);
mEditSignal = (EditText) findViewById(R.id.signal_strength);
}
private class ServiceStateHandler extends Handler {
public void handleMessage(Message msg) {
Log.i("LocateMe", "In handleMessage : " + msg.what);
switch (msg.what) {
case MY_NOTIFICATION_ID:
ServiceState state = mPhoneStateReceiver.getServiceState();
int cid = state.getCid();
int lac = state.getLac();
int signal = mPhoneStateReceiver.getSignalStrength();
mEditCid.setText("" + cid);
mEditLac.setText("" + lac);
mEditSignal.setText("" + signal);
break;
}
}
}
}
Download the sources and Application - LocateMe.zip
UPDATE: Nov 30, 12:37 EST - Version 2.0 is here
About this entry
You’re currently reading “Android - Access Cell Phone details (Cell-Id, LAC, Signal Strength),” an entry on Show me the code! - By Davanum Srinivas
- Published:
- 11.29.07 / 9am
- Category:
- Uncategorized
- Tags:
8 Comments
Jump to comment form | comments rss [?] | trackback uri [?]