I want a code to get IMEI and show in textviwe
This is my code:
public class Main extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String IMEI;
IMEI = retrieve_IMEI.get_dev_id().toString();
TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText(IMEI);
}
public static class retrieve_IMEI {
public static String get_dev_id() {
Context ctx = null;
// Getting the Object of TelephonyManager
TelephonyManager tManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
// Getting IMEI Number of Device
String Imei = tManager.getDeviceId();
return Imei;
}
}
And i use READ_PHONE_STATE permission
When i run my code, i get the force close. How can i fixed