Android SMS setting unique ID

2019-04-09 23:10发布

问题:

I am attempting to develop an Android application that sends and receives SMS messages (among other things)

i wish to have my apps SMS messages easily identifiable. I didnt want to use the SMS message body for this unique identifier, i thought there must be an SMS message attribute i can use. sadly i have failed to find one or track down a technical spec for SMS messages in general.

does anyone know if the SMS message standards have an ID field that can be se programmatically?

回答1:

No, there is not. You can see the contents of an standard SMS message on page two of this document, and on this page.



回答2:

The way I have handled this is by setting an SMS listener with a higher priority than the system SMS listener that looks for a unique string in all received texts.

If the SMS contains the string I handle it in the application and discard the SMS so that I do not litter the users inbox.

The users message alert tone doesn't even go off. It works quite well.

See this post for more info on how to do this:

Can we delete an SMS in Android before it reaches the inbox?



回答3:

i know it's been 4 years . but in case anyone passes through this question. yes SMS has unique id called _id and you can identify SMS through it.

for more info please refere to this answer.