6

I have a BroadcastReceiver statically registered in my Android application, which handles incoming SMS messages, like this:

        <receiver
            android:name=".receivers.SmsReceiver"
            android:exported="true" >
            <intent-filter android:priority="100" >
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>

Lint marks this with a warning, beacuse the Receiver is exported without needing any permissions from the caller. If I set the exported property to false, the system fails to call my Receiver upon getting an SMS message.

So which permission should I require from the System when registering my Receiver to handle incoming SMS messages?

Edit:

I'm not asking for the "uses-permission" tag that enables my application to receive SMS messages. I'm asking for proper "android:permission" value for my Receiver, so only the system can send broadcast messages like that, and another application can't spoof an event like that for my application.

E.g.:

        <receiver
            android:name=".receivers.SmsReceiver"
            android:exported="true"
            android:permission="com.android.permission.SOME_PERMISSION_ONLY_THE_SYSTEM_HAS">
            <intent-filter android:priority="100" >
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>
Zsombor Erdődy-Nagy
  • 16,864
  • 16
  • 76
  • 101
  • is the above issue related to [this](http://code.google.com/p/android/issues/detail?id=36536) ? – nandeesh Sep 11 '12 at 13:55
  • Unfortunately, no. I'm defining the correct tags so that when the system receive an SMS, I get notified about it and Lint does not sees this as an error. It tells me however, that my Receiver need a "permission" tag, so that only trusted sources may notify my sms-receiver (which should be the system only). But I couldn't find which permission I should use. – Zsombor Erdődy-Nagy Sep 13 '12 at 15:55
  • I am doing something similar HERE!!! http://stackoverflow.com/questions/14452808/sending-and-receiving-sms-mms-in-android – Etienne Lawlor Jan 22 '13 at 20:48

1 Answers1

-2

Use android:priority="2147483647" instead android:priority="100" because suppose you have using any application which priority is high comparing to your priority as u set then your broadcast never notify that. also check this permission in your mainfest uses-permission android:name="android.permission.RECEIVE_SMS"

Rishabh Agrawal
  • 861
  • 2
  • 15
  • 25
  • The value must be an integer, such as "100". Higher numbers have a higher priority. The default value is 0. The value must be greater than -1000 and less than 1000.as suggested in DOC ref http://developer.android.com/guide/topics/manifest/intent-filter-element.html – Pranav Mar 04 '16 at 12:51