F:\work> mvn archetype:generate -DarchetypeCatalog=http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml2: http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml -> galatea-archetype (null)
groupId: org.eoti.android.phone
artifactId: PhoneIDTest
version: 1.0-SNAPSHOT
package: org.eoti.android.phone
F:\work> cd PhoneIDTest
F:\work\PhoneIDTest> mvn clean install
Add this to your AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Add this convenience method to your PhoneIDTestActivity:
private void showMessage(String msg)
{
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
Insert this into the end of your onCreate method:
TelephonyManager mgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);Redeploy (mvn clean install) and run the app.
switch(mgr.getPhoneType())
{
case TelephonyManager.PHONE_TYPE_CDMA:
showMessage("CDMA");
break;
case TelephonyManager.PHONE_TYPE_GSM:
showMessage("GSM");
break;
case TelephonyManager.PHONE_TYPE_NONE:
showMessage("NONE");
break;
default:
showMessage("Unknown phone type");
}
showMessage("Device ID: " + mgr.getDeviceId());
showMessage("Version: " + mgr.getDeviceSoftwareVersion());
showMessage("Number: " + mgr.getLine1Number());
showMessage("Country: " + mgr.getNetworkOperatorName());
showMessage("Sim Serial#: " + mgr.getSimSerialNumber());
showMessage("Subscriber ID: " + mgr.getSubscriberId());
showMessage("Operator: " + mgr.getSimOperatorName());
No comments:
Post a Comment