terminated phone call, the Telephony Manager will broadcast an action_phone_state_changed Intent.By registering a manifest Intent Receiver that listens for this Broadcast Intent, as shown in the snippet below, you can listen for incoming phone calls at any time, even if your application isn’t running. Note that your application needs to request the read_phone_state permission to receive the phone state changed Broadcast Intent.The Phone State Changed Broadcast Intent includes up to two extras. All such broadcasts will include the EXTRA_STATE extra, whose value will be one of the TelephonyManager.CALL_STATE_* actions described earlier to indicate the new phone state. If the state is ringing, the Broadcast Intent will also include the extra_incoming_number extra, whose value represents the incoming call number.The following skeleton code can be used to extract the current phone state and incoming call num¬ber where it exists:public class PhoneStateChangedReceiver extends BroadcastReceiver {©Overridepublic void onReceive(Context context, intent intent) {String phoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE); if (phoneState.equals(TelephonyManager.EXTRA_STATE_RINGING)) {String phoneNumber =intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);Toast.makeText(context,"incoming Call From: " + phoneNumber,Toast.LENGTH_L0NG).show()}INTRODUCING SMS AND MMSIf you own a mobile phone that’s less than two decades old, chances are you’re familiar with SMS messaging. SMS is now one of the most-used communication mechanisms on mobile phones.SMS technology is designed to send short text messages between mobile phones. It provides support for sending both text messages (designed to be read by people) and data messages (meant to be consumed by applications). Multimedia messaging service (MMS) messages allow users to send and receive messages that include multimedia attachments such as photos, videos, and audio.Because SMS and MMS are mature mobile technologies, there’s a lot of information out there that describes the technical details of how an SMS or MMS message is constructed and transmitted over the air. Rather than rehash that information here, the following sections focus on the practicalities of sending and receiving text, data, and multimedia messages from within Android applications.
đang được dịch, vui lòng đợi..
