Android Question notification on simulated sms

seby8181

Member
Licensed User
Longtime User
Hi,
i used this code to simulate a new sms arrived...
B4X:
Sub AddMessageToLogs(body As String, address As String)
  Dim r As Reflector
  r.Target = r.CreateObject("android.content.ContentValues")
  r.RunMethod3("put", "address", "java.lang.String", address, "java.lang.String")
  r.RunMethod3("put", "body", "java.lang.String", body, "java.lang.String")
  Dim ContentValues As Object = r.Target
  r.Target = r.GetContext
  r.Target = r.RunMethod("getContentResolver")
  r.RunMethod4("insert", Array As Object( _
  r.RunStaticMethod("android.net.Uri", "parse", Array As Object("content://sms/inbox"), _
  Array As String("java.lang.String")), _
  ContentValues), Array As String("android.net.Uri", "android.content.ContentValues"))
   
End Sub

...and in manifest:


B4X:
AddPermission("android.permission.WRITE_SMS")
AddPermission("android.permission.READ_SMS")

But is possible to insert also regular notification like a normal sms arrived?
Thanks a lot!
 

bsnqt

Active Member
Licensed User
Longtime User
Thanks to reply so speedy!
I noted that when arrive a new "normal" sms, phone found also my new "simulated" sms...
is possible impose a control for new sms arrived?

Thanks for your help! ;)

It is because when a new sms arrives it will trigger the system notification process, which will also read your "new" (simulated) sms in the inbox as well, then it will report that you have both. But Erel is right that "Adding a message to the database will not cause any notification" itself.
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
I don't think so, in my knowledge (I can be wrong), the notification is sent by Telephony SMS provider once a new ("normal") sms arrives... Adding a new one ("simulated") to database is not equal to a "normal" reception of an sms.

1) Maybe you try to send an intent similar to "android.provider.Telephony.SMS_RECEIVED" though I never tried it earlier so I am not sure whether it works?

2) Another way is once you add your simulated sms to database, you can also send your own notification, simulating the system one (as it is a simulated sms, so no matter the notification is "simulated" or "natural" :)).
 
Upvote 0
Top