Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String getPhone() {
- TelephonyManager phoneMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- if (ActivityCompat.checkSelfPermission(activity, wantPermission) != PackageManager.PERMISSION_GRANTED) {
- return "";
- }
- return phoneMgr.getLine1Number();
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- List<SubscriptionInfo> subscription = SubscriptionManager.from(getApplicationContext()).getActiveSubscriptionInfoList();
- for (int i = 0; i < subscription.size(); i++) {
- SubscriptionInfo info = subscription.get(i);
- Log.d(TAG, "number " + info.getNumber());
- Log.d(TAG, "network name : " + info.getCarrierName());
- Log.d(TAG, "country iso " + info.getCountryIso());
- }
- <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Add Comment
Please, Sign In to add comment