how to send image to a contact number in android - android

I am able to send normal message to a number through SmsManager. But I want to send image(mms) along with text message. I know it can be sent through Intent with ACTION_SEND, but I am using SmsManager. But searching about it, some sources say it might not be possible. But has someone made it possible?
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);

Related

Delete message from outbox/inbox

I have built an app that send an SMS Message through SmsMenager:
SmsManager sms = SmsManager.getDefault()
sms.sendTextMessage(number, null,text, null, null);
Everything goes well. The sms is sent without any intervention of the user.
My goal now is to delete the message sent from the inbox/outbox. Is it possible?

Prevent sms from going to outbox

I am making an app that sends an SMS programmatically.
I don't want it to pop up in the built in SMS app.
Incoming SMS doesn't matter for now.
Is there a way to prevent an sms from going to the 'outbox'?
This is how I send:
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
After KitKat, no. See the post here: http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html
Before KitKat, it won't go to the "Outbox" so it isn't an issue.
You can try a third-party solution like www.superdupersms.com (that's the only one I know of, and I'm a part of the development team).

Using the native sms app to send an sms without launching itself

I want to send an SMS, but not using the SmsManager class. I want to do it with the native SMS app which is there on an Android phone.
And here is the twist : I do NOT want to launch the native app while doing it. Is there some format of intent which can send an sms directly (given the sms-body and the phone number to send it to) via the native app (without the user having to click 'send').
I googled the same, but all results and responses simply launched the native sms, waiting for user to manually send the SMS. I have seen this being implemented in some apps like 'MightyText' and wish to implement in my app as well.
Please help !
Using the SmsManager will send the sms through the system but will not put it in the SMS content provider as was mentioned earlier. Hence any native messaging app will not see it.
To do so, you have to add it manually via the SMS content provider AFTER you send the message normally via SmsManager. Here's some sample code to help:
ContentValues values = new ContentValues();
values.put("address", "+12345678"); // phone number to send
values.put("date", System.currentTimeMillis()+"");
values.put("read", "1"); // if you want to mark is as unread set to 0
values.put("type", "2"); // 2 means sent message
values.put("body", "This is my message!");
Uri uri = Uri.parse("content://sms/");
Uri rowUri = context.getContentResolver().insert(uri,values);
And that's all. After that you'll notice that it's added and the native messaging app displays it normally.
Please click "accept" answer if it works out for you.
Ok, so you want to send a SMS, without using SmsManager and plus it should show up in your native SMS app list?
Firstly, you cannot send SMS bypassing SmsManager. If you look at the source code of all native messaging app for Samsung Galaxy Nexus, it will invoke SmsManager on button click.
so, the below piece of code as posted above is correct
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);
Secondly, after sending the message, native apps put it into into SMS ContentProvider
follow this How to save SMS to inbox in android?
Word of caution is that now adding to this is not supported. So you may have to resort to a hack to add it into the sent box.
If you only have ACTION_SENDTO, then, of course, any application that can send will pop up.
You need to add a filter for SMS
with URL. See https://stackoverflow.com/a/2372665/94363
or with content type https://stackoverflow.com/a/10613013/94363
I have done something similar in a project I was working on. You need to use SmsManager
It would be something like this -
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNumber, null, message, null, null);
You can use this to send an SMS programatically.
Try this:
String phoneNo = textPhoneNo.getText().toString();
String sms = textSMS.getText().toString();
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, sms, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}

detect the application that sent sms in android

I'm new to android Develpoment
my first application is ant-spy
I try to detect the application that sent sms (that is listening to send an sms )
I ask you to help me this application and if possible give me a source code for DECT application waiting to send sms or a code that resemble.
Thanks.
This code is used to send sms:
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(smsNumberToSend, null, smsTextToSend, null, null);

Send an SMS without the delivery report

I used this good tutorial http://mobiforge.com/developing/story/sms-messaging-android for sending SMS in my android app.
If I do not want the provider to send me the delivery report when sending a sms, is it enough to set the delivery intent to NULL?
Like instead of:
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
use
sms.sendTextMessage(phoneNumber, null, message, sentPI, NULL);
or is there an additional setting to prevent SMS delivery reports?
Are you getting an SMS (or a System-Message) from your Provider, which tells you that the SMS was successfully send? If so, you might activated some "alert when successfully send" thing in your SMS app.
Otherwise yes, if you don't want the Intent, just pass 'null'. But i don't know why you'd do that.

Categories

Resources