please help! I want share my photo into Instagram. I use Intent for sharing, but I don't need at all list in Share, such as - Facebook, Instagram, Gmail, Bluetoth... etc. I need only Instagram. I want share photo into Instagram by only onclickListener. How can do it? thanks.
It is asked a long time ago. But the clear answer is not here. That's why, I want to answer as well.
I have been used that code below and it worked. It redirects to crop screen of instagram directly. (Of course, Instagram app must be installed on the device.)
...
Intent intent = createInstagramIntent("file://" + filePath);
startActivity(intent);
...
and
private Intent createInstagramIntent(String uriString) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(uriString));
shareIntent.setPackage("com.instagram.android");
return shareIntent;
}
Create your custom sharing screen that call instagram.
Related
Hello I'm new to android studio I have built an app when you take a photo from the camera app see it in an ImageView and share it
I have made a share button:
case R.id.shrbtn:
startshare();
break;
the share button go to this method to start sharing the photo
I have added internet permission and the button don't do anything:
private void startshare() {
Bitmap bmp=viewToBitmap(Image,Image.getWidth(),Image.getHeight());
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
Uri phototUri = Uri.parse(String.valueOf(Bitmap.createBitmap(bmp)));
shareIntent.setData(phototUri);
shareIntent.putExtra(shareIntent.EXTRA_STREAM,phototUri);
startActivity(Intent.createChooser(shareIntent, "Share Via"));
}
can anyone tell me what is missing?
Send it by an intent and get it from startActivityForResult() method.
This tutorial explains it well
This sounds to me like an issue regarding the button callback itself. Have you make sure that the method have been called? Maybe you should set breakpoints to identify the issue?
Maybe you should take a look here (as your share intent looks wrong): https://stackoverflow.com/a/7662164/6268503
I know this question has been asked many times and in many different ways (see here and here). However, I haven't been able to achieve it in the following way:
The picture and the title are in the same section. Then, there is the rest with the link in another section. I have achieved to put text and image together, but the picture is on the top of the text.
This is the code I am using:
Intent intent = new Intent();
intent.setComponent(new ComponentName(packageName, ri.activityInfo.name));
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, shareContentByWhatsapp(contentType));
intent.putExtra(Intent.EXTRA_STREAM, getImage());
intent.setType("image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Does anyone know how to obtain same result than in the picture?
As image you have shared,
In this case you just need to share the link,
image and link related content will be fetched by WhatsApp itself.
You can do like this:
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "http://www.google.com");
mContext.startActivity(whatsappIntent);
or, you can share image with caption.
But, image you have shared, is whatsapp's functionality :-)
My question is simple, i want to make an intent to instagram app from my app, but i want to show the timeline (just like we are open the instagram app manually), how can i do this?
This method is working to show an user profile, but i want to show the timeline.
private void createInstagramIntent() {
//Creamos intent de instagram y lanzamos la activity
Uri uri = Uri.parse("http://instagram.com/_u/javierjsanchezg");
Intent share = new Intent(Intent.ACTION_VIEW, uri);
share.setPackage("com.instagram.android");
startActivity(share);
}
Instagram is mainly a Photo Sharing App and you need to specify the content type. Check the code below. It will open the Instagram App Home Screen of the App is installed in the device and says no app can perform this action if not installed.
Intent is just a way to connect with other apps and it has minimized
control over the other App.
Uri uri = Uri.parse("http://www.google.com");
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hi Android Share intent");
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
sharingIntent.setPackage("com.instagram.android");
startActivity(Intent.createChooser(sharingIntent, "Choose"));
Happy Coding..!!
You can simplify your code to :
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com")));
Now as per the user's timeline it depends if it is private or public in order to view it. Hope it helps.
I need to share text and one image from my application via a share intent. I read this article. I thought it would be easy to create share intent. But it is not so easy, because there is a problem with sharing via Facebook.
I need to share some text and one image, which is stored in device. My first attempt looked like this:
The first try
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/img.jpg")));
shareIntent.putExtra(Intent.EXTRA_TEXT, "My custom text...");
shareIntent.setType("image/jpg");
startActivity(Intent.createChooser(shareIntent, getString(R.string.label_share)));
I tried this code and in applications like Gmail, Google+, Google Keep, etc, everything works fine. But Facebook did not work fine.
There is no my text ("My custom text...") in this screenshot. So I have tried something else.
The second try
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/img.jpg")));
shareIntent.putExtra(Intent.EXTRA_TEXT, "My custom text...");
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, getString(R.string.label_share)));
And the result of this is here:
There is no text and also no image in this screenshot.
I also tried to change type to image/* and */*, but it did not help. I do not know what is wrong. I just need to share some text and image via Facebook. The first try works well for other applications, but for Facebook not.
Can someone help me, please?
Your first attempt is OK, Facebook does not allow sharing text this way, they say "Pre-filling these fields erodes the authenticity of the user voice."
I am trying to share a text containing a link via facebook.
My code work perfectly with the facebook messenger application. But not via Facebook app.
In Facebook app i am getting a sharing view with an empty edittext. I Don't want to integrate facebook api and give sharing authorisation. I don't want to do that. I think it can be done only via extras and intent.
My sharing code:
private void ShareWebView(){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, mTitle);
startActivity(Intent.createChooser(intent, "Share with"));
}
You cannot. See Android and Facebook share intent
And especially this link provided in one of the comment : http://developers.facebook.com/bugs/332619626816423
Walkaround: If you do not want to implement it using android SDK
and you want to use
private void ShareWebView(){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, mTitle); // MUST contain 1 url
startActivity(Intent.createChooser(intent, "Share with"));
}
make sure that mTitle contains one LINK.
Why to do that: Although the fact that facebook doesn't work properly it grubs the first url or look like url from the mTitle and post-it as share url. It also automatically catch a subtitle and a photo from that url so the post/share is quite acceptable most of the time avoiding long code implementations!