Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: where is the android.provider.Telephony.SMS_RECEIVED?

Tags:

android

I'm writing an App that needs to receive sms, everyone use "android.provider.Telephony.SMS_RECEIVED_ACTION" intent action in their code, but it looks like API level 17 doesn't support it anymore! where it is now? I also didn't find SMS_RECEIVED_ACTION in "android.telephony" class! please someone tell me, I'm totally confused. should I use older APIs?

like image 640
Shayan_Aryan Avatar asked Aug 28 '13 17:08

Shayan_Aryan


People also ask

What is android provider telephony?

android.provider.Telephony. The Telephony provider contains data related to phone operation, specifically SMS and MMS messages, access to the APN list, including the MMSC to use, and the service state. Note: These APIs are not available on all Android-powered devices.

What is pdus in android?

(PDU stands for Protocol Data Unit.) The mode that a GSM/GPRS modem or mobile phone is operating in determines the syntax of some SMS AT commands and the format of the responses returned after execution.

What is telephony app used for?

What is Telephony? The telephony system is a software framework to provide mobile phones with telephony functionalities, such as voice call, Video call, SMS,MMS ,data service, network management and so on. Architecture:Telephony framework for Android has four layered Architecture. as per Android P.


1 Answers

The Telephony class does not have a documented API until API 19 (4.4 - KitKat). The absence of the class does not mean what you are trying to do does not work. You need to request this permission:

<uses-permission android:name="android.permission.RECEIVE_SMS"/>

And if you register your receiver in your manifest it will look something like this:

    <receiver android:name=".SmsIntentReceiver">
        <intent-filter android:priority="1">
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
    </receiver>

From the android.provider.Telephony AOSP:

public static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_RECEIVED";

Here is a grepcode.com reference to the source:

http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/2.3.2_r1/android/provider/Telephony.java/?v=source

Notice the "@hide" just before the class declaration - it is there, but not exposed to devs. That is why it is not recognized in the ADT.

like image 101
Jim Avatar answered Nov 03 '22 13:11

Jim