Question

HI I was wondering if there was way that I could place a message in my inbox when application is started. What I wanna do is that when I run my application I want that a message from number let say that is 034556343, body of the message would be "Application has started" should be in my Inbox of the phone. any Ideas?

Was it helpful?

Solution

If you want to manually put some SMS to your inbox with a sender name then,

ContentValues my_values = new ContentValues();
values.put("address", "034556343");//sender name
values.put("body", "Application has started");
getContentResolver().insert(Uri.parse("content://sms/inbox"), my_values);

You will also need the following permissions:

<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS"/>

Keep in mind that the SMS content provider isn't actually part of the SDK, and this code is not guaranteed to work on all past, present and future devices.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top