I would like to delete a spec开发者_JS百科ific SMS from Inbox in Android , How Can I query for a specific SMS ?
You can just send or receive sms in a normal Android app which is not a default sms app but you cant delete it.All devices above 4.4 can have only one default sms app.You can ask user to make your app as a default sms app by placing a permission in manifest,After thisvall sms will be written to the sms provider using your app only but its completely on user whether he chooses your app for sending and receiving sms.If your app is a default sms app then you can delete the sms. The manifest for making your app a default sms app is here: ...
<!-- BroadcastReceiver that listens for incoming MMS messages -->
<receiver android:name=".MmsReceiver"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<!-- Activity that allows the user to send new SMS/MMS messages -->
<activity android:name=".ComposeSmsActivity" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</activity>
<!-- Service that delivers messages from the phone "quick response" -->
<service android:name=".HeadlessSmsSendService"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</service>
</application>
To get access to Androids SMS-Inbox, you can use the "SMSManager". A tutorial on this can be found here.
Also, i found this older post. I'm not sure if this is the perfect way anymore, check if some of the used code is deprecated.
精彩评论