How to Delete a MMS message from a particular number in Android? - android

I want to delete a MMS message of a particular phone number in android. How can i do it?
I am using content://mms-sms/conversations to get list of MMS messaged and tried with the following query:
this.getContentResolver().delete(
Uri.parse("content://mms-sms/conversations/" + ThreadId),
"address=?", new String[] { "contact number" });`
But it works only for sms and not for mms. Can someone tell me what can we do to delete particular MMS?
Thanks

Please check below detailed Tutorial link for Read,Write,Delete and update MMS in Android
MMS in Android. Part 2. Working with MMS storage
Also Try this
Uri msgUri = ContentUris.withAppendedId(Mms.Inbox.Content_Uri,"1");
SqliteWrapper.delete(this, getContentResolver(), msgUri, null, null); (or) getContentResolver().delete(msguri, null, null);
Reference
Edit:
here is the method syntax
public static Uri withAppendedId (Uri contentUri, long id)
and Uri is the MMS inbox storage url in content provider
for example SMS Inbox Uri is "content://sms/inbox"
also read this page for MMS storage Uri info given here
Save/Create MMS in inbox Android

Related

ContentResolver -- how to get file path of attachment

I need help in accessing the attachment received in an email.
I have setup intent filter for my activity and on clicking the attachment in the gmail app, my activity is launched with intent containing following Uri.
content://gmail-ls/xxxx#gmail.com/messages/2407/attachments/0.1/BEST/false
I have tried following query and filename returned is null.
String[] projection = {MediaStore.MediaColumns.DATA};
Cursor c = context.getContentResolver().query(uri, projection, null, null, null);
if (c.moveToFirst()) {
fileName = c.getString(0);
}
Anyone, please let me know how can I access the file received in the attachment ?
Thanks.
Anyone, please let me know how can I access the file received in the attachment ?
There isn't necessarily a file at all, let alone one that you have direct access to. Gmail, in particular, had better be storing its attachments in a place where other apps cannot access them directly.
To use the attachment, use the Uri with a ContentResolver to get an InputStream on it.

How to send MMS without prompting to send it via gmail ,whatsapp or something else ?

When I am Using this code to send mms to specific user it shows me popup to send it via gmail,whatsapp,gtalk,message and etc. But in my case I just want to send that image as an mms to specific number that i will define in address field whithout showing any popup can any body tell me How to do this ? I googled for this and find lot of stuff on it.
Here is my code*strong text*
public void sendData(int num){
String fileString = "..."; //put the location of the file here
Intent mmsIntent = new Intent(Intent.ACTION_SEND);
mmsIntent.putExtra("sms_body", "text");
mmsIntent.putExtra("address", num);
mmsIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(fileString)));
msIntent.setType("image/jpeg");
startActivity(Intent.createChooser(mmsIntent, "Send"));
}
Using an intent (like you did) is the preferred way because it's easy to implement and let the user choose his favorite app for the task of sending the MMS.
That being said you can still implement yourself the operation and send the MMS programmatically from your app by crafting and sending the appropriate HTTP request.
The following answer will provide you all the information you need: How to send image via MMS in Android?

Sending sms in android

When I use the following code:
String phoneNumber="0527276513";
Uri uri = Uri.parse("smsto:" + phoneNumber.toString());
Intent smsSIntent = new Intent(Intent.ACTION_SENDTO, uri);
String smsBody="hii";
smsSIntent.putExtra("sms_body", smsBody.toString());
startActivity(smsSIntent);
The code opens the default application for sending SMS in my phone with the SMS body but the message doesn't get sent.
How do I send an SMS dynamically?
It is simple. Before making any changes please update your manifest by adding the following line:
<uses-permission android:name="android.permission.SEND_SMS"/>
And in your method/function use the following code:
String phoneNumber = "myphonenumber";
String message = "mymessage";
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);
Note that on Android 4.4 (KitKat) and higher devices, only the default SMS app can send text messages, per the blog post.
Assuming your app is not a full fledged SMS replacement app, the approach you have outlined is the correct one to ensure your app works on all Android versions.

In Android Where is sms outgoing saved if that sms sended by class SmsManager, not application messager default

I want read information of sms outgoing that sended by class SmsManager in Android not by default application messenger in device. Any idea for help me? Many thank all of you!
Nothing is saved by SmsManager. The messages are sent to their recipient over the mobile network, and that is it.
Individual apps may save messages that they also send via SmsManager. The details of which apps save what would depend upon the apps.
Please follow the following two steps:
1. Send your message
2. Insert the message to "sent" messages box
SmsManager smsManager = SmsManager.getDefault();
String address = "address here";
String text = "text message here";
// Send you message
smsManager.sendTextMessage(address, null, text, null, null);
Uri uri = Uri.parse("content://sms/sent/");
ContentValues values = new ContentValues();
values.put("address", address);
values.put("body", text);
// Insert the message to "sent" messages box
getContentResolver().insert(uri, values);
PS: You can check the complete code here

How to get a contact's facebook id or url from native contacts / content resolver?

How to get the facebook id or url of a contacts that's been synced to the native contacts app via Facebook sync adapter?
I went through different urls, but didn't see any info regarding facebook.
I tried
ContactsContract.Data.CONTENT_URI
ContactsContract.CommonDataKinds.Email.CONTENT_URI
ContactsContract.CommonDataKinds.Phone.CONTENT_URI
ContactsContract.Contacts.CONTENT_URI
as URIs already in the code below:
Uri uri = ContactsContract.Data.CONTENT_URI;
Cursor c = getContentResolver().query(uri, null, null, null, null);
while (c.moveToNext()) {
for (int i=0; i<c.getColumnCount(); i++) {
Log.d(TAG, c.getColumnName(i) + ": " + c.getString(i));
}
Log.d(TAG, "==================================");
}
I do get a column value like
contact_status_res_package: com.facebook.katana
in this dump, and I also get the contacts status (contact_status column), but nowhere do I see the facebook url or id of this contact.
Got the reply from on the Google Group (http://groups.google.com/group/android-developers/browse_thread/thread/95110dd7a1e1e0b4):
Access to Facebook friends via the
contacts provider is restricted to a
handful of system apps by the provider
itself. Other applications cannot
read that data.
Therefore now I fetch an cache all contact names/id mappings via FB Graph api (http://graph.facebook.com/me/friends) and use that for the id lookup.

Categories

Resources