Manipulate Native SMS App - android

Im sending SMS in my application using Intent like
Intent si= new Intent(Intent.ACTION_VIEW);
si.putExtra("sms_body", "some text");
si.putExtra("address", "123456789");
si.setType("vnd.android-dir/mms-sms");
startActivity(si);
is there a way i can restrict the user from adding any additional text, disable the native application's EditText area, is that possible...

instead of Opening SMS APP via intent Why not use SMS Manager( method sendTextMessage ) and send SMS from your app..
http://developer.android.com/reference/android/telephony/SmsManager.html
note requires permission : http://developer.android.com/reference/android/Manifest.permission.html#SEND_SMS

Related

Autoresponse for Line

How to achieve the android line automatically reply message function?
Receiving messages using NotificationListenerService, what you need to do now is to reply to the messenger when you receive the message, and automatically do not touch the screen at all?
The following is the message text to the line, and you want to manually select the object to be transferred.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("line://msg/text/" + text));
startActivity(intent);
But I would like to send a message to a specific person manually.
A similar problem is Automatic reply for whatsapp messages approach, but I was going to automatic-reply-for-line not whatsapp.
There are other products seen on this function, but can try all the methods have tried to achieve the function I want ....
So is this possible?

send sms without inputting contact number

i already know the code how to send sms by typing the number and the message, but what i want to know is it possible to send message only without typing the contact number? Here’s my situation, im working at water district, I’m making app for reporting leak thru text, what i want to happen is, the reporter is only need to type the message then send, without inputting the number. We only have 1 hotline number, so I don’t think the reporter need to type the contact number everytime the reporter text us, he just need to type the message then click send only.
send sms without inputting contact number
Following code works without inputting the number again and again. The address attribute stores the number(hotline number) and When user clicks on report it default takes you to messaging app with number already stored and allow to write the text and go.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setType("vnd.android-dir/mms-sms/");
intent.putExtra("address", your_hotline_number);
intent.putExtra("sms_body", " ");
startActivity(intent);
Try this it's working for me:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", "12345", null)));
Keep the recipient number in a constant field as
public static final String recipientNo = "*********";
Then if you use implicit intent the add below code
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + recipientNo));
intent.putExtra("sms_body", message);
startActivity(intent);
or if you use SmsManager,
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);
and add permission in AndroidManifest.xml
<uses-permission android:name="android.permission.SEND_SMS"/>

Launch a different sms app to send sms programmatically without opening it

This below approach opens the app but doesn't do anything.
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String phoneNumber = "phone number here";
String text = "Hi belated happy diwali";
Intent smsIntent = getPackageManager().getLaunchIntentForPackage("sun.way2sms.hyd.com");
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", phoneNumber);
smsIntent.putExtra("sms_body", text);
startActivity(smsIntent);
}
});
As per my knowledge, like default SMS Manager you can't send message directly with other apps....like way2sms / whatsapp. If and only if they are providing there SDK and with that option.
Do you know the 'key' -> "address" and "sms_body" are using by way2sms app to receive your data!!!!
For Eg: Facebook you can post directly with ur app by using some user permissions.
If you are using a third party app the best you can do is launch the third party app with the data pre filled just like the native app.
If the third party app provides any support for sending sms in the background (like a broadcast or something) then you can do it. Although the chances of any app having such functionality is low

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?

Android: how to pre-populate an SMS message

I am writing an application that needs to pre-populate an SMS message with the first name of the contact when using the stock android SMS messenger.
For example if my contacts name is Alex Smith.
When I select Alex Smith to type a message to, I want the text box to already have
'Alex, '
at the beginning of the SMS.
Please how can I achieve that?
Fetch the contact name from contacts, and do like as follows:
String contactName = "Alex"; // get it from selected contact
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:" + phoneNumber ) );
intent.putExtra( "sms_body", contactName+"," );
startActivity( intent );
Just look over here:
Send SMS via intent
You use a Intent to send the SMS and attach some pre defined text via the EXTRA_TEXT attribute. Quite easy to do. And it works for the normal SHARE intent as well.
You can't change system apps, but you can send "share intent" from your app to SMS App. As you remember, when you push "share" button in some apps, you can share smth with SMS. (You'll have SMS with text that app put in intent). SO, put contact's name in "share intent" and send it to SMS app.
it's bit late, but i hope it will help future users.
void prePopulateSMS(final String mblNumVar, final String smsMsgVar) {
Log.d(TAG, "prePopulateSMS called. smsMsgVar: " + smsMsgVar);
Intent smsIntent = new Intent(android.content.Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", mblNumVar);
smsIntent.putExtra("sms_body", smsMsgVar);
startActivity(smsIntent);
}

Categories

Resources