telephony

How to get phone number from an incoming call?

*爱你&永不变心* 提交于 2019-11-26 07:27:11
问题 How do I get the phone number when there is an incoming call in Android? 回答1: Make a Broadcast receiver say ServiceReceiver assign its action in Manifest. <receiver android:name=".ServiceReceiver" > <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> </receiver> Add a PhoneStateListener to your TelephonyManager, PhoneStateListener having override onCallStateChanged() with Incoming number parameter. Thats it. ServiceReceiver.Java public class

android default making default sms app

柔情痞子 提交于 2019-11-26 05:18:35
So I am following this Tutorial here on setting my SMS as default, but for some reason my code is not working. I have tried to look this up as much as possible, but everything points back to this same tutorial or has been outdated. Do I need a receiver as well? Can someone explain what I am doing wrong? The Code: @Override protected void onResume() { super.onResume(); Log.i("MainAcitvity", "On Resume Called"); // Only do these checks/changes on KitKat+, the "mSetDefaultSmsLayout" has its visibility // set to "gone" in the xml layout so it won't show at all on earlier Android versions. final

Make a phone call programmatically

风格不统一 提交于 2019-11-26 03:04:15
问题 How can I make a phone call programmatically on iPhone? I tried the following code but nothing happened: NSString *phoneNumber = mymobileNO.titleLabel.text; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]]; 回答1: Probably the mymobileNO.titleLabel.text value doesn't include the scheme tel:// Your code should look like this: NSString *phoneNumber = [@"tel://" stringByAppendingString:mymobileNO.titleLabel.text]; [[UIApplication sharedApplication] openURL:[NSURL

Detect if an outgoing call has been answered

℡╲_俬逩灬. 提交于 2019-11-26 02:36:51
问题 Once ACTION_NEW_OUTGOING_CALL has been broadcasted, I need to capture the following event of the other party answer. Could you advice on how to achieve that please? I know it is possible as the android dialer app changes the green android icon to the person\'s photo excatly when they pick up. Thanks! UPDATED: I\'ve had a look at the source of the app on Android handling the outgoing calls. I noticed the following method in ContactsUtils : /** * Kick off an intent to initiate a call. */ public

How to detect when phone is answered or rejected

徘徊边缘 提交于 2019-11-26 02:35:39
问题 I managed to prepare an activity when the phone is ringing. Now I need to know how to cancel this activity when I anwser the phone or I reject the call.Do I call EXTRA_STATE_IDLE?EXTRA_STATE_OFFHOOK? Any ideas? <receiver android:name=\".IncomingBroadcastReceiver\"> <intent-filter> <action android:name=\"android.intent.action.PHONE_STATE\"/> </intent-filter> </receiver> public class IncomingBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent

How do I set my app as the default SMS app?

余生颓废 提交于 2019-11-26 02:13:20
问题 I am following this tutorial on setting my app as the default SMS app, but for some reason, my app does not appear in the list of available options. I have tried to research this as much as possible, but everything points back to that same tutorial, or is outdated. Do I need a <receiver> as well? Can someone explain what I am doing wrong? The code: @Override protected void onResume() { super.onResume(); Log.i(\"MainAcitvity\", \"On Resume Called\"); // Only do these checks/changes on KitKat+,

How to programmatically answer/end a call in Android 4.1?

牧云@^-^@ 提交于 2019-11-26 01:06:19
问题 I am writing an android app in which I need to answer an incoming call, do some work and then end the call. After all the Googling I could find two different ways to achieve this both of which do not work with recent versions of Android, specifically after 4.1, Jelly Bean. I.) Access \"com.android.internal.telephony.ITelephony\" using Java Reflection in the Broadcast receiver for \"android.intent.action.PHONE_STATE\". Below sample code can be found in hundreds of related post: public class

How to programmatically answer/end a call in Android 4.1?

天大地大妈咪最大 提交于 2019-11-26 00:35:32
I am writing an android app in which I need to answer an incoming call, do some work and then end the call. After all the Googling I could find two different ways to achieve this both of which do not work with recent versions of Android, specifically after 4.1, Jelly Bean. I.) Access "com.android.internal.telephony.ITelephony" using Java Reflection in the Broadcast receiver for "android.intent.action.PHONE_STATE". Below sample code can be found in hundreds of related post: public class PhoneCallReceiver extends BroadcastReceiver { Context context = null; private static final String TAG =

How to hang up outgoing call in Android?

℡╲_俬逩灬. 提交于 2019-11-26 00:32:45
问题 I am developing an application where one of the things we need is to control the outgoing call, at least to be able to stop it from our application. I\'ve tried using Intent.ACTION_CALL from an existing activity: Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(\"tel:\" + phoneNumber)); startActivity(callIntent); But stopping the call seems to be disallowed through the API. Can you suggest some workaround? For example: enabling airplane mode during the call? Just an example; this

What regular expression will match valid international phone numbers?

元气小坏坏 提交于 2019-11-26 00:27:48
I need to determine whether a phone number is valid before attempting to dial it. The phone call can go anywhere in the world. What regular expression will match valid international phone numbers? \+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d| 2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]| 4[987654310]|3[9643210]|2[70]|7|1)\d{1,14}$ Is the correct format for matching a generic international phone number. I replaced the US land line centric international access code 011 with the standard international access code identifier of '+', making it mandatory. I also changed the