telephonymanager

How to monitor SIM state change

僤鯓⒐⒋嵵緔 提交于 2019-11-26 19:51:14
I'd like to be able to do some stuff when the SIM state change, i.e. play a sound when SIM PIN is required, but I think there are no Broadcast events that can be intercepted by a broadcast receiver for this... registering for android.intent.action .PHONE_STATE does only tell you when the CALL-STATE changes.. An alternative can be starting a service that registers a PhoneStateListener and reacts upon a LISTEN_SERVICE_STATE (when the state is OUT-OF-STATE it can get the SIM state from the TelephonyManager and look if the state is SIM_STATE_PIN_REQUIRED). So, my questions are: 1) Is there any

How to know whether I am in a call on Android?

耗尽温柔 提交于 2019-11-26 17:21:05
I want to know whether I am in a call. If I am in a call then start the service (service part is clear). How do I do this? While attending the call I need to call the service... I am unaware of how to do this? Any help? You need broadcast receiver ... In manifest declare broadcast receiver ... <receiver android:name=".PhoneStateBroadcastReceiver"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE"/> </intent-filter> </receiver> Also declare uses-permission ... <uses-permission android:name="android.permission.READ_PHONE_STATE" /> The broadcast receiver class ... package x

Why ITelephony.aidl works?

。_饼干妹妹 提交于 2019-11-26 15:16:19
问题 I saw some SO posts which discussed about how to end a phone call programmtically, for example, this one. Yep, people focus on the result but no one actually explain the reason why it works? I tried the code, it works well. But I would like to know more details about what is going on underneath? Why by creating the ITelephony.aidl , the android hidden internal ITelephony interface is exposed in our project? How does ourself created ITelephony.aidl & the automatically generated java (/gen

to get phone number programmatically in Android

こ雲淡風輕ζ 提交于 2019-11-26 14:22:51
问题 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

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

谁都会走 提交于 2019-11-26 14:06:14
问题 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

end incoming call programmatically

安稳与你 提交于 2019-11-26 12:04:21
问题 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

tm.getDeviceId() is deprecated?

核能气质少年 提交于 2019-11-26 09:54:30
问题 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); 回答1: 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

How to get current SIM card number in Android?

人盡茶涼 提交于 2019-11-26 08:59:13
问题 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? 回答1: I think sim serial Number and sim number is unique. You can try this for get

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

橙三吉。 提交于 2019-11-26 08:05:59
问题 I need help checking whether a device has a sim card programatically. Please provide sample code. 回答1: 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();

Programmatically obtain the phone number of the Android phone

会有一股神秘感。 提交于 2019-11-26 01:18:08
问题 How can I programmatically get the phone number of the device that is running my android app? 回答1: Code: TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE); String mPhoneNumber = tMgr.getLine1Number(); Required Permission: <uses-permission android:name="android.permission.READ_PHONE_STATE"/> Caveats: According to the highly upvoted comments, there are a few caveats to be aware of. This can return null or "" or even "???????" , and it can return a