Sending MMS into different Android devices - android

I need to send MMS. Into my hero this code looks ugly but works:
Intent sendIntent = new Intent("android.intent.action.SEND_MSG");
sendIntent.putExtra("address", toText);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
sendIntent.putExtra("sms_body", textMessage);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/jpeg");
startActivity(sendIntent);
But it seems to me that on the other devices it doesn't work at all.
I want to send directly to main messaging app without any choices(the better solution of course - direct from my app). Because not sure that all of them would handle it properly.
If anybody could recommend any third-party library I'll be appretiate.

Have you tried something like this (change to your need and add images etc...):
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mmsto:<number>");
intent.putExtra("address", <number>);
intent.putExtra("subject", <subject>);
startActivity(intent);
The above is the best I could come up with which works on HTC/Nexus/SE from 1.6 to 2.2.

send from your app ?
before startActivity, you can
intent.setClassName("your package name", "your class name");
startActivity(intent);

You could try something like this.Which will launches all the apps which can handle the intent.
intent.setAction(Intent.ACTION_SEND);
//In case of multiple file
intent.setAction(Intent.ACTION_SEND_MULTIPLE);
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, <List of uris>);
intent.putExtra(Intent.EXTRA_STREAM, <singleUri>);
intent.setType("*/*");
startActivity(intent);

Related

How to make app picker for sharing text permanent in Android?

I'm trying to make refer and earn activity in my appSo I want to permanently display a few apps like whatsapp, etc for the user to click on them and share directly.I'm using Intent to share the referral code but it pops up the apps list when the user clicks share.The code I'm using is,
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "This is a message");
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "Share via"));
How can I make the app chooser permanent for a few apps?
The app chooser is not intended to be displayed permanently. Therefore you will have to create simple buttons or icons and create an intent that refers to the desired app directly, by setting the package of the intent.
E.g. to share sth with WhatsApp use sth like this:
Intent sendIntent = new Intent();
// here comes the magic
sendIntent.setPackage("com.whatsapp");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
Depending on the type of content you want to share and the apps you want to share with, it makes sense to reuse the code to create the intent and just set the respective package and eventually some additional parameters.
You will need package name of app and a Intent.
change ACTION_VIEW to ACTION_SENDTO
set the Uri as you did set the
package to whatsapp
Intent i = new Intent(Intent.ACTION_SENDTO,
Uri.parse("content://com.android.contacts/data/" + c.getString(0)));
i.setType("text/plain");
i.setPackage("com.whatsapp"); // so that only Whatsapp reacts and not the chooser
i.putExtra(Intent.EXTRA_SUBJECT, "Subject");
i.putExtra(Intent.EXTRA_TEXT, "I'm the body.");
startActivity(i);
You can refer this link for More:
Send text to specific contact (whatsapp)
Sending message through WhatsApp
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("*/*");
intent.setPackage("com.whatsapp");
intent.putExtra(Intent.EXTRA_TEXT, "your text content");
startActivity(intent)
I am facing same problem for share tamil font content in Whatsapp. I found the solution, this setType("*/*") share full content.

Google mobile compose page URL

I want to send a predifined google+ message via android, but I\m not sure I found the right URL for that. I found https://plus.google.com/app/plus/mp/430/#~loop:view=compose , but it's not setting my text. Is there actually another official app URL that could allow that? Twitter has the one bellow. 10x
Intent i = new Intent();
i.putExtra(Intent.EXTRA_TEXT, msg);
i.setAction(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://mobile.twitter.com/compose/tweet"));
ctx.startActivity(i);
You can share text and images on Google+ with the ACTION_SEND intent.
Example:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "Hello World!");
shareIntent.setType("text/plain");
startActivity(shareIntent);
If you would like to target the Google+ app directly, you can call setPackage on the shareIntent before calling startActivity.
shareIntent.setPackage("com.google.android.apps.plus");

Android: action_send intent is not showing facebook

I recently implemented the action-send intent to share a plain text. Facebook is installed and updated on my phone but only "Googlemail" and "Textmessage" are shown as options for sharing my text.
A short code snippet:
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, item.getTitle());
intent.putExtra(
android.content.Intent.EXTRA_TEXT,
(item.getDescription());
startActivity(Intent.createChooser(intent, "Send..."));
Any suggestions what's wrong with my app?
Normally I would think that I dont have to implement the whole facebook sdk for my simple purpose?!
Thanks in advance
The MIME type to use is text/plain, not plain/text.

Intent with setType("message/rfc822") for Android API Level before 2.3.3

I have a problem with setting type "message/rfc822" for intent to send e-mail with file attachment on Android emulator. I have to use setType("message/rfc822") because the file doesn't have standard MIME-type (SQLite database) and I am trying to avoid a lot of applications in the select list for user's choice. For all API Levels before 2.3.3 I have an error:
java.lang.RuntimeException:
Unable to start activity ComponentInfo{my.cashwatcher/my.cashwatcher.SendEmailActivity}:
android.content.ActivityNotFoundException:
No Activity found to handle Intent { act=android.intent.action.SEND typ=message/rfc822
(has extras) }
In the case of API Level, 2.3.3 code works fine and error doesn't appear. Is it a problem with the Android emulator or old APIs!?
Code:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("message/rfc822");
sendIntent.putExtra(Intent.EXTRA_EMAIL , new String[]{appPrefs.getEmail("email")});
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), DATABASE_PATH)));
sendIntent.putExtra(Intent.EXTRA_TEXT, "body_of_email");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "APPLICATION_NAME");
startActivityForResult(sendIntent, EMAIL_SEND_RESULT);
First, "to avoid a lot of applications in select list for user's choice", use ACTION_SENDTO and a mailto: Uri.
Second, what you are experiencing is not "a problem of Android emulator" nor "old APIs". You need 1+ applications that are capable of handling the ACTION_SEND Intent and a MIME type of message/rfc822. There is no guarantee that any given device will support that combination, let alone any given emulator. Your code needs to handle that, just as if you use ACTION_GOBBLEDYGOOK or a MIME type of thisis/sonotreal or whatever.
I have made an application that uses URI example as you desired:
if(v.getId()==R.id.button3)
{
intent=new Intent(Intent.ACTION_SEND);
intent.setData(Uri.parse("mailto"));
String[]to={"akshkatheria#gmail.com","megakatheria#gmail.com"};
intent.putExtra(Intent.EXTRA_EMAIL, to);
intent.putExtra(Intent.EXTRA_SUBJECT, "hello");
intent.putExtra(Intent.EXTRA_TEXT, "hi");
intent.setType("message/rfc822");
chooser=intent.createChooser(intent, "send mail");
startActivity(chooser);
}
This is the solution. Use the below code, works perfectly...Got the
solution after research.... :)
Intent testIntent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + "blah blah subject" + "&body=" +
"blah blah body" + "&to=" + "sendme#me.com");
testIntent.setData(data);
startActivity(testIntent);

Android Email vs MMS Raw Attachment?

I have this code to send an emai with an audio attachment that is coming from the raw folder:
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("Audio/basic");
i.putExtra(Intent.EXTRA_SUBJECT, "mySubject");
i.putExtra(Intent.EXTRA_TEXT, "myBody");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://[my_package]/raw/sound"));
startActivity(i);
This code works fine.
I tried to adapt the same code so that I can send MMS message with audio attachment from the raw folder.
I came up with this:
String uri= "mmsto:";
Intent i = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
i.putExtra("sms_body", "myBody");
i.putExtra("compose_mode", true);
i.putExtra(Intent.EXTRA_STREAM, Uri.parse"android.resource://[my_package]/raw/sound"));
startActivity(i);
The code opens an SMS application. However, there isn't any attachment to the message !
Am I doing it right? Please help me with that.
To those who might be interested:
MMS Functionality is a bit unreliable, not well-documented feature in Android. So, the existed solutions are supposed to work but they will not work all the time on all the devices. You can't depend on them, yet.

Categories

Resources