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);
Related
I'm using SmsMessage to send sms via my application . this is my code :
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(tel, null, text, null, null);
it works fine and I've no problem with sending messages. the only issue is that I want to save sent sms in android message inbox.
How can I do so ?
Sms content provider can help you to write data into message inbox:
ContentValues values = new ContentValues();
values.put("address", tel);
values.put("body", text);
values.put("date", "135123000000");
getContentResolver().insert(Uri.parse("content://sms/sent"), values);
Permission required:
<uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
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);
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
My Android App is using the following code to send an SMS Message:
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(smsMessage.getNumber(), null, smsMessage.getText(), sentPI, deliveredPI);
However, is it possible to save the outgoing message so that it is displayed in the default SMS app, just as if the user used the default app to send it?
Thanks
you must insert your smsMessage into default SMS_database
like this
public void insertSMS(String address,String body){
private ContentResolver resolver = null;
resolver = context.getContentResolver();//context is your instance of Activity
ContentValues values = new ContentValues();
values.put("address", address);
values.put("body", body);
resolver.insert(Uri.parse("content://sms/sent"), values);
}
I want to show some information as an sms in my application.
But SmsManager and BroadcastReciever can not create sms and notify on phone itself.
How can I send a fake sms to myself programmatically? Any ideas, workarounds or any class for research... ?
Thanks.
PROOF OF CONCEPT
Call SMS list
Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(
new ComponentName("com.android.mms","com.android.mms.ui.ConversationList"));
startActivity(intent);
READ SMS
cursor c= getContentResolver().query(uri, null, null ,null,null);
startManagingCursor(c);
c.moveToFirst();
String body = c.getString(c.getColumnIndexOrThrow("body")).toString();
String number = c.getString(c.getColumnIndexOrThrow("address")).toString();
c.close();
Toast.makeText(getApplicationContext(), number, Toast.LENGTH_LONG).show();
Write SMS
ContentValues values = new ContentValues();
values.put("address", "SENDER");
values.put("body", "foo bar");
getContentResolver().insert(Uri.parse("content://sms/inbox"), values);
MANIFEST
<uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
ISSUE
There is no event after that therefore android doesnt known if there is some new message.
You can send SMS from another instance of Android Emulator. That could be done through Emulator control View in Eclipse or using Telnet.