2

Im can send sms with this code :

 SmsManager manager = SmsManager.getDefault();
    manager.sendTextMessage("5556", null, "Hi Havij", null, null);

But I dont like my message go in Inbox ! I want dont show it Nowhere ...

محمد
  • 139
  • 3
  • 11
  • If the messages are being written to the Provider without your app having explicitly done so, then you're running on KitKat or above. In that case, your app will need to be the default SMS app to prevent those writes. Any non-default app using the SmsManager methods to send will have its messages written automatically. The default is responsible for writing its own, and can choose not to do so. However, writing a full-blown SMS app is not trivial. – Mike M. Dec 14 '14 at 05:31
  • my app is not a sms sender application ! I want send some data to my server ... However How I can delete my message after sent it ? such as sms blocker apps ? – محمد Dec 14 '14 at 05:40
  • Currently, the only way I know to send SMS as non-default without it showing in the Provider is to send data SMS. I have seen one app that somehow deletes messages immediately after they're written without being the default, but I've not yet found out their method. – Mike M. Dec 14 '14 at 05:47
  • thanks ! can u give a sample or link for this ? – محمد Dec 14 '14 at 06:24
  • 1
    If you mean an example of data SMS, [this post](http://stackoverflow.com/questions/3757229/how-to-send-and-receive-data-sms-messages) should help you. – Mike M. Dec 14 '14 at 06:45

2 Answers2

2

One possible solution might be deleting that SMS, But according to Google Docs after 4.4 no app can delete messages except the default messaging app:

Also, the system now allows only the default app to write message data to the provider, although other apps can read at any time. Apps that are not the user's default can still send messages

and for more info I suggest u see this.

UPDATE

after a little search I found what you need but as I told you before it seems its impossible in android 4.4 but if you want to do such work with lower versions of android please take a look at this

Community
  • 1
  • 1
Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78
  • after a little search i found what you need. I updated my answer @user3787191 – Milad Faridnia Dec 15 '14 at 05:41
  • Im need do in all version ! my code work on all version under 4.4 But in 4.4 my message save in defaul app ! – محمد Dec 15 '14 at 18:36
  • not sure but try removing uses-sdk part in ur manifest file. it might works. – Milad Faridnia Dec 16 '14 at 06:42
  • just see a comment from one of the most famous android programmers that repeated my answer. Please take a look at this post specially CommonsWare's comment: http://stackoverflow.com/questions/28000013/send-and-receive-request-via-sms-instead-of-http – Milad Faridnia Jan 17 '15 at 13:48
0

One possible solution is you may send data SMS.

 SmsManager smsManager = SmsManager.getDefault();   
 byte[] messageInBytes = stringMessage.getBytes();  
 smsManager.sendDataMessage(Mobile_no, null, SMS_PORT, messageInBytes , null, null);