开发者

Reading text from SMS, and show it as text view

开发者 https://www.devze.com 2023-04-04 03:45 出处:网络
I am trying to create app, that will get the text from SMS, and use it in textview. So something like this, message is recived, i check if it is message I want, then i extract te开发者_JS百科xt, save

I am trying to create app, that will get the text from SMS, and use it in textview. So something like this, message is recived, i check if it is message I want, then i extract te开发者_JS百科xt, save it to string, and then show this string in textview. Any suggestions from where should i start, any examples plese ??


You can start here for handling received SMS.


First I would listen for SMS incoming, and on incoming SMS show a notification. Then if the user opens your app, update your display using this to get the data you want:

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 around with it a little. It Should have all of the data you need (distinguish SMSs by timestamp)

0

精彩评论

暂无评论...
验证码 换一张
取 消