Show sms notification - android

i programmed a fake sms sender and have problem to show sms notification after inserted,
i use this code to insert sms :
ContentValues values = new ContentValues();
values.put("address", "123456");
values.put("body", "Test !");
values.put("status", -1);
values.put("date", String.valueOf(System.currentTimeMillis()));
getContentResolver().insert(Uri.parse("content://sms/inbox"), values);
and tested this code, but email app return force close :
Intent a = new Intent("android.provider.Telephony.SMS_RECEIVED");
byte[] by =(byte[])(SmsMessage.getSubmitPdu("123456", "123456", "Test !", false).encodedMessage);
Object[] vrs = {by};
a.putExtra("pdus",vrs);
sendBroadcast(a);

Related

SMS Provider Android

I would handle sms with my app.
I use this code to insert the message into provider android:
ContentValues values = new ContentValues();
values.put("address", phoneNumber);
values.put("date", System.currentTimeMillis());
values.put("body", text);
values.put("type", 1);
values.put("read", 1);
if (Build.VERSION.SDK_INT >= 19)
values.put(Inbox.DATE_SENT, System.currentTimeMillis());
context.getContentResolver().insert(Uri.parse("content://sms"), values);
The message is insert correctly but when i see it i reply an error.
The date of receipt is correct, but the date of dispatch is not correct (it's set to 1 January 1970).
How can i set it?
Thank you!

Native SMS app resending sms when I store all sms in its outbox

I'm sending sms from my android application and storing it into phone sms outbox.
When I switch off my phone and switch on than all sms which I've stored into outbox are resent to its corresponding number.
How I can oppose this resending sms?
My sms storing code is:
ContentValues values = new ContentValues();
values.put("address", "something");
values.put("subject", "something");
values.put("body", "something");
values.put("type", "4");
values.put("status", Common.STATUS_VALUE_DELIVERED_SUCCESS);
values.put("error_code", Common.ERROR_CODE);
long milli = getTimeInMillis(mi.Date);
path = Uri.parse("content://sms/");
Uri uri = resolver.insert(path, values);

How can I insert on SMS into inbox with operator name?

I want tosave operator Name also but i can't find any appropriate tag for that Any body please help me on This.
ContentValues values = new ContentValues();
values.put("address", originatingAddress);
values.put("body", sampleContent);
values.put("date", timeStamp);
context.getContentResolver().insert(Uri.parse("content://sms/inbox"), values);
For getting operator name you can use:
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE));
String OperatorName = manager.getNetworkOperatorName();
and then use it in your code as you want OR like below:
ContentValues values = new ContentValues();
values.put("address", originatingAddress);
values.put("body", sampleContent);
values.put("date", timeStamp);
values.put("body", OperatorName);
context.getContentResolver().insert(Uri.parse("content://sms/inbox"), values);

How to save incoming messages in encrypted format

I need to receive sms from this a particular number, encrypt it and later sent in the inbox. This way my message is protected from reading by anyone else who handles my phone.
Try something like this
ContentValues values = new ContentValues();
values.put("address", "123456789");
values.put("body", "foo bar");
getContentResolver().insert(Uri.parse("content://sms/inbox"), values);
I hope this helps

Android: Updating the sent box afer sending an sms

My app sends an sms and I would like to update the phone sent box
as if the sms was sent bu the user.
How can this be done ?
You need to add this lines after smsManager.sendTextMessage(number, null,desc, sentPI, deliveredPI);:
ContentValues values = new ContentValues();
values.put("address", number);
values.put("body", desc);
getApplicationContext().getContentResolver().insert(Uri.parse("content://sms/sent"), values);

Categories

Resources