telephonymanager

getAllCellInfo returns null in android 4.2.1

送分小仙女□ 提交于 2019-11-27 08:57:45
My Android version is 4.2.1 and I am trying to make use of TelephonyManager.getAllCellInfo() method. In my manifest file I have the ACCESS_COARSE_UPDATES , ACCESS_COARSE_LOCATION , ACCESS_FINE_LOCATION permissions. However that method returns null . From TelephonyManager.getAllCellInfo() javadoc: This is preferred over using getCellLocation although for older devices this may return null in which case getCellLocation should be called. Some sources report that this method is only implemented on CDMA/LTE devices, and other types of devices (including GSM/LTE ones) will return null. Where

to get phone number programmatically in Android

馋奶兔 提交于 2019-11-27 08:56:15
I am using the code TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE); mPhoneNumber = tMgr.getLine1Number(); to get the phone no programatically in android . But this is working fine only for one sim card. If i test this code by inserting other sim card, it is giving null . I am trying to find the solution for this. please help me. I have also included READ_PHONE_STATE permission in Manifest . I want to uniquely identify the sim card. IS there any other way to do this. please let me know. Maidul I think Sim serial Number is unique. You can try

How to get phone number of a device programmatically [duplicate]

╄→гoц情女王★ 提交于 2019-11-27 08:36:14
This question already has an answer here: Programmatically obtain the phone number of the Android phone 15 answers I am trying to get phone no using following method: private String getMyPhoneNumber() { TelephonyManager mTelephonyMgr; mTelephonyMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); //String imsi = mTelephonyMgr.getSubscriberId(); String phnNo = mTelephonyMgr.getLine1Number(); if (phnNo == null) { phnNo = getNoFromWatsApp(); } return phnNo; } private String getNoFromWatsApp(){ AccountManager am = AccountManager.get(this); Account[] accounts = am.getAccounts();

how to resolve this error “com.android.internal.telephony cannot be resolved to a type” in android

风格不统一 提交于 2019-11-27 08:09:22
i am creating simple call filter application which restrict unwanted calls. i use following code to restrict call but i am unable to resole problem of this line in below code " com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tm); " it show the error message com.android.internal.telephony cannot be resolved to a type in android how to resolve this error . public class CallBlockReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub } private void getTeleService(Context context) {

getLine1Number() Returns blank, not null [duplicate]

家住魔仙堡 提交于 2019-11-27 06:45:41
问题 This question already has answers here : MSISDN : Is it a SIM Card Data? Why all The Provided Function (from Blackberry and Android) to fetch MSISDN not reliable? (3 answers) Closed 2 years ago . I want to get Mobile Number of Device. I have used following code reference by Alex Volovoy's This Link TelephonyManager tMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); String mPhoneNumber = tMgr.getLine1Number(); Log.d("msg", "Phone : "+mPhoneNumber); OUTPUT in Logcat: Without

end incoming call programmatically

十年热恋 提交于 2019-11-27 06:34:33
This is a familiar question in SO. and what I need is to end call programmatically. I have searched a lot... http://androidsourcecode.blogspot.in/2010/10/blocking-incoming-call-android.html http://androiddesk.wordpress.com/2012/08/02/blocking-a-call-without-user-intervention-in-android/ Rejecting Incoming call in android How to programmatically answer/end a call in Android 4.1? http://www.emoticode.net/android-sdk/block-incoming-and-outgoing-phone-calls-programmatically.html How to block calls in android how to block a mobile number call and message receiving in android application development

tm.getDeviceId() is deprecated?

安稳与你 提交于 2019-11-27 05:17:05
I'm getting the IMEI and device Id's, so here I am getting a problem getDeviceId() is deprecated. TelephonyManager tm = (TelephonyManager) getSystemService(this.TELEPHONY_SERVICE); imei = tm.getDeviceId(); device = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID); getDeviceId() Returns the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for CDMA phones. Return null if device ID is not available. This method was deprecated in API level 26. Use (@link getImei} which returns IMEI for GSM or (@link getMeid} which returns MEID for CDMA

How to get the country code for CDMA Android devices?

北城以北 提交于 2019-11-27 04:47:32
问题 Does anyone know how to retrieve the country code information for Android devices under CDMA networks? For all others, you can just use the TelephonyManager for that: String countryCode = null; TelephonyManager telMgr = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); if (telMgr.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) countryCode = telMgr.getNetworkCountryIso(); } else { // Now what??? } I searched a bit but did not find any useful information that would lead

How can I check whether the Sim Card is available in an android device?

白昼怎懂夜的黑 提交于 2019-11-26 22:02:04
I need help checking whether a device has a sim card programatically. Please provide sample code. Charlie Collins Use TelephonyManager. http://developer.android.com/reference/android/telephony/TelephonyManager.html As Falmarri notes, you will want to use getPhoneType FIRST of all, to see if you are even dealing with a GSM phone. If you are, then you can also get the SIM state. TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); int simState = telMgr.getSimState(); switch (simState) { case TelephonyManager.SIM_STATE_ABSENT: // do something break; case

How to get current SIM card number in Android?

本小妞迷上赌 提交于 2019-11-26 21:43:49
I want to know user mobile number in Android. I used this code but I'm not getting number. TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); String n = tm.getLine1Number(); Permission: <uses-permission android:name="android.permission.READ_PHONE_STATE"/> Is it compulsory to save number in android mobile settings --> about phone --> status --> myphone number Any idea on this? Dipak Keshariya I think sim serial Number and sim number is unique. You can try this for get sim serial number and get sim number and Don't forget to add permission in manifest file.