How to save incoming messages in encrypted format - android

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

Related

Restore SMS in inbox

I want to restore sms in phone, but code seems to have no effect.
I read sms, and get sms from thread_id number 4, then I want to add sms in this conversation, using those lines :
ContentValues initialValues = new ContentValues();
initialValues.put("address", "0644552211");
initialValues.put("date", String.valueOf(System.currentTimeMillis()));
initialValues.put("body", "test test");
initialValues.put("type", 1);
initialValues.put("thread_id", 4);
initialValues.put("read", 1);
getContentResolver().insert(Uri.parse("content://sms/inbox"), initialValues);
But nothing seems to be inserted.
EDIT
insert(...) method return that : content://sms/inbox/0
Answer found :
insert(...) method always return : content://sms/inbox/0
because my app was not default sms app !

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);

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);

How can I send fake sms to myself without mobile network usage?

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.

Categories

Resources