Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I fake send SMS messages AND a system notification? Programmatical approach?
    primarykey
    data
    text
    <p> Update: To state this first: I'm looking for a programmatical way. I know it is easily possible with emulators, but I'm looking for a way to have it implemented in an actual application on my phone.</p> <p>I've been playing around with this for a while now, although I can write messages to the inbox or outbox with</p> <pre class="lang-java prettyprint-override"><code>ContentValues values = new ContentValues(); values.put("address", "5551"); values.put("body", "the text of this message"); getContentResolver().insert(Uri.parse("content://sms/inbox"),values) </code></pre> <p>and of course</p> <pre class="lang-java prettyprint-override"><code>&lt;uses-permission android:name="android.permission.WRITE_SMS"/&gt; &lt;uses-permission android:name="android.permission.SEND_SMS"/&gt; &lt;uses-permission android:name="android.permission.READ_SMS"/&gt; </code></pre> <p>The <code>WRITE_SMS</code>is there just for some of the following, because with all the things I tried I could not get the system to receive a notification. I thought about investigating the code of the built-in SMS app but could not find it.</p> <p>Here come the things I tried:</p> <pre class="lang-java prettyprint-override"><code>context.getContentResolver().notifyChange(Uri.parse("content://sms/inbox",null); </code></pre> <p>has just the same non-effect like:</p> <pre class="lang-java prettyprint-override"><code>Intent intent = new Intent("android.provider.Telephony.SMS_RECEIVED"); byte[] b = (byte[])(SmsMessage.getSubmitPdu("5551","5552","some_text",false).encodedMessage); Object[] vrs = {b}; intent.putExtra("pdus",vrs); sendBroadcast(intent); </code></pre> <p>As a workaround right now I'm calling the sms-list:</p> <pre class="lang-java prettyprint-override"><code>Intent intent = new Intent("android.intent.action.MAIN"); intent.setComponent(new ComponentName("com.android.mms","com.android.mms.ui.ConversationList")); startActivity(intent); </code></pre> <p>Any ideas or hints?</p> <hr> <p>Ok, so I have been browsing the android code, especially <a href="http://www.java2s.com/Open-Source/Android/android-platform-apps/Mms/com/android/mms/transaction/MessagingNotification.java.htm" rel="nofollow">http://www.java2s.com/Open-Source/Android/android-platform-apps/Mms/com/android/mms/transaction/MessagingNotification.java.htm</a></p> <p>To my understanding all I'd need to do is call the public static <code>MessagingNotification.blockingUpdateAllNotifications(context)</code> after writing the SMS. Is there any way I can access this method?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload