So far I've been able to send an image as an attachment but I would like to make it part of the email's body. I know in iOS it is possible to simply pass a link to the image in an but this does not seem to work in Android. I tried using this:
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(removeImgTags("<img.../>"));
But this only appends an object that is however not parsed as an image. I also tried the other version of this method:
Html.fromHtml(url, new MyImageGetter(), null)
And this had the same effect. So is this even possible?
Related
I am creating message having text and url. But when I call share intent it only shows Extra text (that is for link) , doesn't show extra subject( that is for text), is there any solution for that?
Guys i need help i aam facing a very strange problem and I would like to hear your opinion i added a share button to share images.
I used
Intent intent = new Intent ();
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity (Intent.createChooser (intent,"Share Using...."));
and it is working perfectly except for one thing if i choose the picture to share then pressed the share button and choose to share via whatsapp or G+ the application loads and the post is created with the chosen image if i backpressed i go back to my app then if i try to share another image and choose whatsapp or g+ both keep showing the old image in the new post and here comes the strange part if i post or send the image the new image is sent to the receipent and not the old image shown in the post. .... any help would be appreciated by the way i have tried using all flags with the intent but the problem persists
You need to pass a new Intent every time you want to post a new value, or clear the current object for that matter.
Can you also elaborate on this one, i didn't quite get what you meant:
if i try to share any other image whatsapp and g+ keep showing the old image in the new post and here comes the strange part if i post or send the image the new image is sent to the receipent
The problem is I have an article that want to share to other apps, and I want to let the user to choose which app to share to. What I want to share is basically:
the title of the article
the URL of the article
the article content as HTML
the URL with some extra text (such as 'http://foo.com/article share from #FooApp')
All of these fields are optional, but I want to share at least one of them.
Such as when share via SMS or twitter, I want to set the content to part 4. when share via Facebook, I want to set 1, 2, 3 together. And when share via email, I want to set subject as 1 and message as 4.
I know (correct me if I'm wrong) every target intent receiver has it's own logic to pick up the fields it needed. So I want to provide as much information as possible and I wrote the following code:
String message = article.getURL() + " #FooApp";
Intent intent = new Intent().setData(Uri.parse(article.getURL())
.putExtra(Intent.EXTRA_SUBJECT, article.getTitle())
.putExtra(Intent.EXTRA_TEXT, message)
.putExtra(Intent.EXTRA_HTML_TEXT, article.getHTML())
.putExtra("sms_body", message)
...
.setType(HTTP.PLAIN_TEXT_TYPE);
startActivity(Intent.createChooser(intent, "Share to"));
But the problem is, it seems like a trick between setData, putExtra, setType.
For some apps appear in the chooser dialog, when I choose, the confirm share window (of that app) display nothing that I set to the intent. (for some other apps they just say failed to fetch resource)
For the putExtra part, when I add or remove some putExtra code, the target intent receivers diff a lot than I expected.
So the question is: am I doing it the wrong way? Are there some guideline for this problem?
I'm developing a very small application for Android 2.3.3.
I want to send an email (through the android email app) containing a jpeg image as an attachment, below the relevat code (tested only with sdk emulator):
public void sendArtwork(View aView){
EditText subj = (EditText)findViewById(R.id.edit_subj);
EditText descr = (EditText)findViewById(R.id.edit_descr);
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("image/jpeg"); // attachment is a jpeg
emailIntent.putExtra(Intent.EXTRA_EMAIL,new String[]{"contribute#unintentional.org"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT,subj.getText().toString()); //get subject from one EditText in the UI
emailIntent.putExtra(Intent.EXTRA_TEXT,descr.getText().toString()); //get body from one EditText in the UI
emailIntent.putExtra(Intent.EXTRA_STREAM, fileURI); // add attachment
startActivityForResult(Intent.createChooser(emailIntent, "Choose Email application:"), EMAIL_CODE);
}
It works as expected: it opens a Chooser, creates an email with the correct address, subject, text and attachment and sends it.
The only thing I'm not able to accomplish is to set the correct mime type for the image: the attachment is received correctly (i can detach it to disk and open it) but without a content type, so the email client (Thunderbird) does not display a preview and is not able to provide an application to open it.
Does anybody have advice on this?
----EDIT
The image file is sent across without any errors: as said, if I save it on disk on my PC and open it using a suitable application (i.e. Picasa) it shows up correctly.
I'm using the same method for sending emails, and have tested on various versions of a few email clients.
Even gmail is inconsitent, some versions sets the mime type of the attachment, others ignore it.
I've came to the conclusion that there is no safe solution. At least not by using an ACTION_SEND Intent.
i´m trying to achieve a solution where the app ask if facebook.katana aka facebook app is installed in your android phone, if it is installed, check if the user is logged, and if it's logged send a picture with a text (better if it is to a folder), if the user is not logged go to the facebook.katana.LoginActivity and log him, after that make the procedure.
I have this working with a Web View, but i'm interested on how to do it using the app if possible, what i got so far is the uncompiled facebook.katana in this URL where i'm testing the activities:
http://xt720.ru/miui-trans/apk-decompiled/Facebook/smali/com/facebook/katana/
I also know that an image can be attached to that app, since can start the facebook app using this:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(Intent.EXTRA_STREAM,imageUri);
emailIntent.setType("image/png");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Whatever");
startActivity(Intent.createChooser(emailIntent, "Send email using"));
This method would be great for an email, but as it says it creates a chooser, but i don't want to let that option open. So i tried something like:
Intent intent = new Intent("android.intent.category.LAUNCHER");
intent.setClassName("com.facebook.katana", "com.facebook.katana.LoginActivity");
startActivity(intent);
Also you can use the ShareLinkActivity to add an extra to your intent like this:
intent.putExtra(Intent.EXTRA_TEXT, "http://www.google.com/");
The problem is that i don't see how to attach the image to the katana, neither, how to add it to a folder, or how to add it through an application, of course this is much easier via facebook API for android, but like i said that's already done, i want to make it with the facebook App, i have tried, attaching the Bundle to the app as a parcelable, with the usual way it is done in the API, but not luck, this is the snippet:
Bundle params = new Bundle();
params.putByteArray("picture", bitmapdata);
params.putString("title", url);
params.putString("message","Wathever message");
and try to send the params, also tried sending only the image, but not luck, maybe i'm not using the right class (see the uncopiled facebook.katana URL) or i´m attaching in a bad way the info, it should work somehow, cause it works for ACTION_SEND, so, anybody knows how to solve any of this problems:
Attach an image to the facebook.katana
Attach an image to the facebook.katana in a folder
Attach an image to the facebook.katana as an external app
Request the log status of the user to the facebook.katana (i think this would be automatically)
Attach the picture, title, message params to the facebook.katana.
Publish as the app that opens the facebook.katana (i.e. publishin with the WebView will show "published from X app"