Android Instagram intent to timeline - android

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.

Related

Android: Is it possible to open the browser from a share intent?

I am wondering if there is a possibility to open the browser out of the share intent. Let me give an example to clarify:
I have an app with news in it. Each news has an url, so that the user can share this link with the known android share intent per whatsapp, bluetooth, hangouts or something else). Now I wonder if it is possible, that the user could also open this link in the browser out of this share intent. So: am I able to tell the intent, that he should also show the opportunity to open the news-url in the browser?
My current share intent looks like the following:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setType("text/plain");
String shareString = news.getLink();
intent.putExtra(Intent.EXTRA_TEXT, shareString);
context.startActivity(intent);
I had this same requirement. I used below code
//Creating intent for sharing
//TODO edit your share link
String shareString = "http://www.stackoverflow.com";
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, shareString);
//Creating intent for broswer
//TODO edit you link to open in browser
String url = "http://www.stackoverflow.com";
Intent viewIntent = new Intent(Intent.ACTION_VIEW);
viewIntent.setData(Uri.parse(url));
Intent chooserIntent = Intent.createChooser(sendIntent, "Open in...");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{viewIntent});
startActivity(chooserIntent);
This answer provides a complete example. You can choose the apps you want from the original share intent list and add your own intent.

Share Intent Not Working With Facebook Messenger

I am send an Intent with the action Intent.ACTION_SEND. This works fine and the user can pick what application to share with and so on.
The issue is when they pick Facebook Messenger to share. All I get is a white, modal screen with "Send to" in the top left and a search icon in the top right.
Here is the code that launches the intent.
Intent appIntent = new Intent(Intent.ACTION_SEND);
appIntent.setType("text/plain");
appIntent.putExtra(Intent.EXTRA_TEXT,"Check out this app. \nhttp://www.boxshark.co.uk");
appIntent.putExtra(Intent.EXTRA_SUBJECT,"Get the Boxshark app");
startActivity(Intent.createChooser(appIntent,"Share"));
I get that Facebook don't allow pre filled text when you use the share intent so my "Check out this app" text is removed. I don't understand however why the Facebook Messenger app is not doing anything however.
Any ideas anyone? Can you see anything wrong with my intent?
PackageManager pm=getPackageManager();
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("image/jpeg");
Uri uri = Uri.parse("android.resource://1/"+2);
i.putExtra(Intent.EXTRA_STREAM, uri);
PackageInfo info=pm.getPackageInfo("com.facebook.orca", PackageManager.GET_META_DATA);
i.setPackage("com.facebook.orca");
startActivity(Intent.createChooser(i, "Share with"));
1.your package name display in 1st line of your file
2.your image int value from srting which want to share
"com.facebook.orca" is facebook massanger package
Its work for me,hope your also
put only link, do not add text with link.
appIntent.putExtra(Intent.EXTRA_TEXT,"http://www.boxshark.co.uk")

Facebook share doesn't work correctly

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!

Android Instagram

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.

Share Text on Facebook from Android App via ACTION_SEND

I have an Android app and it supports sending text via other apps. It therefore uses the ACTION_SEND intent and the EXTRA_TEXT field. The chooser presents me with all apps that can handle such an intent. Those are Twitter, Email, ... and Facebook. But when I select Facebook it opens the browser and goes to the following page:
http://m.facebook.com/sharer.php?u=mytext
It shows my text and the submit button. But when I press the submit button nothing happens. The page just loads again.
I think maybe it is only possible to send URLs via the Facebook App. Could that be?
Did anyone manage to send text via ACTION_SEND through the Facebook Android app?
To make the Share work with the facebook app, you only need to have suply at least one link:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "Wonderful search engine http://www.google.fr/");
startActivity(Intent.createChooser(intent, "Share with"));
This will show the correct sharing window but when you click on share, nothing happends (I also tried with the official Twitter App, it does not work).
The only way I found to make the Facebook app sharing work is to share only a link with no text:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "http://www.google.fr/");
startActivity(Intent.createChooser(intent, "Share with"));
It will show the following window and the Share button will work:
Apparently it automatically takes an image and text from the link to populate the share.
If you want to share only text, you will have to use the facebook api: https://github.com/facebook/facebook-android-sdk
06/2013 :
This is a bug from Facebook, not your code
Facebook will NOT fix this bug, they say it is "by design" that they broke the Android share system : https://developers.facebook.com/bugs/332619626816423
use the SDK or share only URL.
Tips: you could cheat a little using the web page title as text for the post.
First you need query Intent to handler sharing option. Then use package name to filter Intent then we will have only one Intent that handler sharing option!
Share via Facebook
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Content to share");
PackageManager pm = v.getContext().getPackageManager();
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList) {
if ((app.activityInfo.name).contains("facebook")) {
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
shareIntent.setComponent(name);
v.getContext().startActivity(shareIntent);
break;
}
}
Bonus - Share via Twitter
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Content to share");
PackageManager pm = v.getContext().getPackageManager();
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList) {
if ("com.twitter.android.PostActivity".equals(app.activityInfo.name)) {
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
shareIntent.setComponent(name);
v.getContext().startActivity(shareIntent);
break;
}
}
And if you want to find how to share via another sharing application, find it there Tép Blog - Advance share via Android
EDITED: with the new release of the official Facebook app for Android (July 14 2011) IT WORKS!!!
OLD: The examples above do not work if the user chooses the Facebook app for sharing, but they do work if the user chooses the Seesmic app to post to Facebook. I guess Seesmic have a better implementation of the Facebook API than Facebook!
So I have a work around, but it assumes you have control over the page you're sharing...
If you format your EXTRA_TEXT like so...
String myText = "Hey!\nThis is a neat pic!";
String extraText = "http://www.example.com/myPicPage.html?extraText=\n\n" + myText;
... then on non-Facebook apps, your text should appear something like this:
http://www.example.com/myPicPage.html?extraText=
Hey!
This is a neat pic!
Now if you update your website such that requests with the extraText query parameter return the contents of extraText in the page's meta data.
<!-- Make sure to sanitize your inputs! e.g. http://xkcd.com/327/ -->
<meta name="title" content="Hey! this is a neat pic!">
Then when Facebook escapes that url to generate the dialog, it'll read the title meta data and embed it into your share dialog.
I realize this is a pretty yuck solution, so take with a grain of salt...
It appears that the Facebook app handles this intent incorrectly. The most reliable way seems to be to use the Facebook API for Android.
The SDK is at this link: http://github.com/facebook/facebook-android-sdk
Under 'usage', there is this:
Display a Facebook dialog.
The SDK supports several WebView html
dialogs for user interactions, such as
creating a wall post. This is intended
to provided quick Facebook
functionality without having to
implement a native Android UI and pass
data to facebook directly though the
APIs.
This seems like the best way to do it -- display a dialog that will post to the wall. The only issue is that they may have to log in first
Check this out : By this we can check activity results also....
// Open all sharing option for user
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, ShortDesc+" from "+BusinessName);
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, ShortDesc+" "+ShareURL);
sharingIntent.putExtra(Intent.EXTRA_TITLE, ShortDesc+" "+ShareURL);
startActivityForResult(Intent.createChooser(sharingIntent, "Share via"),1000);
/**
* Get the result when we share any data to another activity
* */
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case 1000:
if(resultCode == RESULT_OK)
Toast.makeText(getApplicationContext(), "Activity 1 returned OK", Toast.LENGTH_LONG).show();
else
Toast.makeText(getApplicationContext(), "Activity 1 returned NOT OK", Toast.LENGTH_LONG).show();
break;
case 1002:
if(resultCode == RESULT_OK)
Toast.makeText(getApplicationContext(), "Activity 2 returned OK", Toast.LENGTH_LONG).show();
break;
}// end switch
}// end onActivityResult
ShareDialog shareDialog = new ShareDialog(this);
if(ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder().setContentTitle(strTitle).setContentDescription(strDescription)
.setContentUrl(Uri.parse(strNewsHtmlUrl))
.build();
shareDialog.show(linkContent);
}
It appears that it's a bug in the Facebook app that was reported in April 2011 and has still yet to be fixed by the Android Facebook developers.
The only work around for the moment is to use their SDK.
if you want to show text put # at the begging of the message you want it will share it as Hashtag

Categories

Resources