Reading text from SMS and displaying it as a text view

I am trying to create an application that will receive text from SMS and will use it in text form. So, something like this, the message is received, I check if there is this message that I want, then I extract the text, save it in a line and then show this line in text form. Any suggestions on where I should start, any plese examples?

0
source share
2 answers

You can run here to process received SMS.

+1
source

First, I would listen to the incoming SMS, and there was a notification on the incoming SMS. Then, if the user opens your application, update it using this to get the data you need:

Uri allMessage = Uri.parse("content://sms/inbox"); ContentResolver cr = getContentResolver(); Cursor c = cr.query(allMessage, null, null, null, null); //shows one message c.moveToNext(); //uncomment to cycle thru ALL messages... This will take AWHILE //while (c.moveToNext()) { for(int i = 0; i != c.getColumnCount(); i++){ String columnName = c.getColumnName(i); String columnValue = c.getString(i); Log.v(TAG, "Col: " + columnName); Log.v(TAG, "Val: " + columnValue); } //} 

Play with him a little. It should have all the necessary data (distinguish SMS messages by timestamp)

0
source

Source: https://habr.com/ru/post/954268/


All Articles