-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.java
More file actions
executable file
·44 lines (33 loc) · 1.31 KB
/
MainActivity.java
File metadata and controls
executable file
·44 lines (33 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package net.learn2develop.simcardid;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.Menu;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TelephonyManager tm = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE);
//---get the SIM card ID---
String simID = tm.getSimSerialNumber();
if (simID != null)
Toast.makeText(this, "SIM card ID: " + simID, Toast.LENGTH_LONG).show();
//---get the phone number---
String telNumber = tm.getLine1Number();
if (telNumber != null)
Toast.makeText(this, "Phone number: " + telNumber, Toast.LENGTH_LONG).show();
//---get the IMEI number---
String IMEI = tm.getDeviceId();
if (IMEI != null)
Toast.makeText(this, "IMEI number: " + IMEI, Toast.LENGTH_LONG).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}