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

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

Related

How to check sent text in OnActivityResult?

I need to be able to check if the user has sent the text I set in my code;
Intent messageIntent = new Intent(Intent.ACTION_SEND)
messageIntent.putExtra(Intent.EXTRA_TEXT, "Text I want to send");
or has changed the prefixed text (on the SMS client app, email client app, or the app that gets launched by the intent) before sending it.
I need to know this because sharing my game link will give a reward to the user, so I need to check if that link is correctly shared.
I would appreciate any answer that could help.
Thanks.
ACTION_SEND isn't documented to return a result. So starting the intent with startActivityForResult() will return the default result: RESULT_CANCELED. That is, unless the receiving app has implemented support for returning a result; which is highly unlikely because it's not part of the documented behavior.
In summary, what you want to do is not possible with any of the common Intents.
You can try this...
String message = "Your Message";
intent.putExtra("IDENTIFIER", message);
And where you are going to receive the message...
String messageReceived = getIntent().getExtras().get("IDENTIFIER").toString();

Send message to user in WhatsApp from my app (Android)

I've gone through plenty of WhatsApp posts here in StackOverflow.
Like these:
Is it legal to use WhatsAPI?
Android Whatsapp/Chat Examples
Sending message through WhatsApp
My question is this. I manage to send a message from my app to WhatsApp for someone that is in my contact list.
However, I want to send a message (NOT SPAM!) to someone who is not on my Contact List through WhatsApp, and I'm unable to do so with the given solutions.
How is it possible?
By the way, how is it possible to fill the body of a WhatsApp text field with a pre-defined message, so the user can edit or send immediately?
"sms_body", or Intent.EXTRA_TEXT doesn't seem to work...
public void shareWhatsApp(String whatsappid) {
try {
Cursor c = getContentResolver().query(ContactsContract.Data.CONTENT_URI,
new String[] { ContactsContract.Contacts.Data._ID }, ContactsContract.Data.DATA1 + "=?",
new String[] { whatsappid }, null);
c.moveToFirst();
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("content://com.android.contacts/data/" + c.getString(0)));
i.putExtra(Intent.EXTRA_TEXT, "Hello!");
startActivity(i);
c.close();
} catch (Exception e) {
Toast.makeText(this, "Install WhatsApp First", Toast.LENGTH_LONG).show();;
e.printStackTrace();
}
}
You should only access Call Log or SMS permissions when your app falls within permitted uses and only to enable your app’s critical core functionality.
Core functionality is defined as the main purpose of the app. This may comprise of a set of core features, which must all be prominently documented and promoted in the app's description. Without the core feature(s), the app is "broken" or rendered unusable.
link -https://support.google.com/googleplay/android-developer/answer/9047303?source=post_page-----9b8226de7827----------------------
You will need some EXTRAS to put into the Intent.
Also you may use the phone number instead of the id.
See this solution here
I answered this question recently and it works very well, please search my answer here:
Send text to specific contact programmatically (whatsapp)
It really works to send a specific message to a specific contact in WhatsApp from your own Android app,
Enjoy! :)

Manipulate Native SMS App

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

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: Send email through basic email app from another application in emulator?

I have a basic handler set up to call the email application in the emulator and send an email. I've set up the email app in the emulator with my info so it's ready to go. However, when I click the button in my app to bring up a compose window I get the prompt that says:
"No applications can perform this action"
Is this just something you can't do with the emulator?
private OnClickListener submitBtn = new OnClickListener(){
public void onClick(View v){
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String emailTo = "test#test.com";
String emailSubject = "Subject";
String emailBody = "Some HTML goes here.";
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,emailTo);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,emailSubject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(emailBody));
startActivity(Intent.createChooser(emailIntent, "Send email in:"));
}
};
Add
intent.setType( "message/rfc822" );
or
intent.setType( "text/html" );
This will cause Android to show a chooser to the user for all applications that can send these types of messages. The html option may put up non-email apps so I use the rfc822 option.
Try a third party app such as K9Mail http://code.google.com/p/k9mail/
The code looks fine, you're hitting some emulator limitations...
I was able to make it work in the emulator by configuring the basic email app with a valid email address.

Categories

Resources