I am using the below code. It opens the Facebook Messenger app, but the image is not shown (with broken image symbol) and sending fails.
List<Bitmap> abc = new ArrayList<Bitmap>();
abc.add(pic);
FacebookDialog.PhotoMessageDialogBuilder builder = new FacebookDialog.PhotoMessageDialogBuilder(LocationShare.this);
builder.addPhotos(abc);
builder.build().present();
is there any problem in the way i add photos? i mean using List
i have mentioned content provider in android manifest.xml
i am able send link using below code.
FacebookDialog.MessageDialogBuilder builder = new FacebookDialog.MessageDialogBuilder(getActivity())
.setLink("https://developers.facebook.com/docs/android/share/")
.setName("Message Dialog Tutorial")
.setCaption("Build great social apps that engage your friends.")
.setPicture("http://i.imgur.com/g3Qc1HN.png")
.setDescription("Allow your users to message links from your app using the Android SDK.");
Did you add a content provider?
If you look at the javadocs for addPhotos (https://developers.facebook.com/docs/reference/android/current/class/FacebookDialog.PhotoMessageDialogBuilder/#addPhotos) it says that a NativeAppCallContentProvider must be specified in your AndroidManifest.
In the docs for NativeAppCallContentProvider (https://developers.facebook.com/docs/reference/android/current/class/NativeAppCallContentProvider/) it tells you how to add the content provider.
You can also have a look in the HelloFacebook sample which has an example of adding the content provider in the AndroidManifest.
Related
My app shares a specific URL to open in other apps, but I want to use a custom URL depending on what app the user is sharing it with. For example, with Gmail I want to use myurl.com?src=gmail, and with FB I want to use myurl.com?src=fb etc.
This normally would have worked with this famous method: https://stackoverflow.com/a/18068122/3015986.
However, in Android 10, that solution no longer works anymore: https://medium.com/#AndroidDeveloperLB/this-wont-work-anymore-on-android-q-1702c19eb7bb
So, what other options are there?
Well there are always options. In this particular case(with the given conditions regarding URL query parameter) I would suggest to create separate sharing method for each platform you want to share your content with rather than use the Android default sharing method.
For example here is a custom sharing for Facebook, etc. The method is quite time consuming though.
But there is a better option to handle such cases. It is a relatively new method to get info about which app was chosen. It is easy. Basically you will need to:
Create a PendingIntent for a BroadcastReceiver and supply its IntentSender in Intent.createChooser() like this:
Intent share = new Intent(ACTION_SEND);
...
PendingIntent pi = PendingIntent.getBroadcast(myContext, requestCode,
new Intent(myContext, MyBroadcastReceiver.class),
FLAG_UPDATE_CURRENT);
share = Intent.createChooser(share, null, pi.getIntentSender());
Receive the callback in MyBroadcastReceiver and look in Intent.EXTRA_CHOSEN_COMPONENT like this:
#Override public void onReceive(Context context, Intent intent) {
...
ComponentName clickedComponent = intent.getParcelableExtra(EXTRA_CHOSEN_COMPONENT);
}
More info here
Though you cannot change your URL for each specific case because the sharing event has already occurred, you can implement separate API call or URL link using which you can gather analytics data, change the outcome of the URL click you sent(if you control the backend, of course) or just show a customized message to the user of your app.
Keep in mind, that for some usecases of this method, URL you share should be unique per user(for ex. to change the outcome of the URL click etc).
Hope it helps.
I am working with a project where the user will be able to share a product from my app to facebook. In this action, the user will edit the following data:
The quote/description of the product.
Set a place for the post.
Share an image from my app gallery.
When the user shares my product it generates a standard hashtag, and the user may select a place for check in.
Here is the image of the desired action.
Sharing product on Facebook
So i followed several tutorials on youtube and the documentation from facebook so i managed to use SharePhoto and Share Link with success. In my share button im using share link and setting the following properties :
String url_link_loja = "www.centauro.com.br";
ShareHashtag.Builder hashtag = new ShareHashtag.Builder();
hashtag.setHashtag("#Olympikus");
String url_imagem = "https://static.olympikus.com.br/produtos/tenis-olympikus-thin-2-feminino/91/D22-0304-791/D22-0304-791_zoom1.jpg?resize=1200:*";
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(url_imagem_test))
.setQuote(url_link_loja)
.setImageUrl(Uri.parse(url_imagem))
.setShareHashtag(hashtag.build())
.setPlaceId("Avenida Paulista")
.build();
shareDialog.show(linkContent);
Then, when i share with my app i get just a thumbnail of the image instead of a full sized image.
Share Dialog on Nexus xl
When i use Share Photo instead, i get the full image on the dialog window just the way i want, however it seems its not possible to add hashtag and quote on this object. I tried to fix this using open graph, so i used the book example from the documentation and tried do add image, but when i do, i get a callback error message that dos not specifies the problem( i already checked, its not the commom namespace error).
So, i need some advice on the matter, any insight will be helpful.
I'm a web developer. I'm currently developing android application on Android Studio using WebView which access my website as an android application. One of my webpage contains many external links. My goal is to make the android application can handle external links like Gmail App does (also like facebook and Line do).
Below is the example of gmail app.
An email contains external link
Link clicked, then application open a new activity acts like a browser without leaving Gmail application
Any idea how to make it?
It is pretty simple. You have to use Chrome Custom Tabs as suggested by Gergely as well in comment. Below is the small functional code that will help you to achieve this.
First add this dependency to your build.gradle(Module:app)
compile 'com.android.support:customtabs:23.4.0'
Second add below function to your code and simply pass string URL to it.
private void redirectUsingCustomTab(String url)
{
Uri uri = Uri.parse(url);
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
// set desired toolbar colors
intentBuilder.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary));
intentBuilder.setSecondaryToolbarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// add start and exit animations if you want(optional)
/*intentBuilder.setStartAnimations(this, android.R.anim.slide_in_left, android.R.anim.slide_out_right);
intentBuilder.setExitAnimations(this, android.R.anim.slide_in_left,
android.R.anim.slide_out_right);*/
CustomTabsIntent customTabsIntent = intentBuilder.build();
customTabsIntent.launchUrl(activity, uri);
}
Rest it will take care itself. Since Chrome Custom Tabs can customised so lot can be done like you can add menu to toolbar. For detailed information you can visit official documentation from Google itself here.
Hope it will help you to start with :)
I have programmatically added Google+ sharing to my app. I have a set of photos that I include with my posts and share with the following code:
private void shareToGooglePlus() {
// Launch the Google+ share dialog with attribution to your app.
PlusShare.Builder share = new PlusShare.Builder(this);
for (String imageFilename : imageList) {
Uri imageUri = Uri.fromFile(new File(imageFilename));
share.addStream(imageUri);
}
share.setText("My images");
share.setType("image/jpeg");
startActivityForResult(share.getIntent(), 0);
}
When this code gets executed, the Google+ app on my phone is started and I get a preview that has the images and text as expected.
However, if I run this more than once and include different images on subsequent runs, the original images show up in the Google+ post preview instead of the new ones. If I submit the post, the correct images show up in the post--the new ones, not the original ones.
I presume the Google+ app has some kind of caching mechanism. Is there a way to programmatically clear that cache so that the correct images show up in the Google+ app post preview?
Thanx in advance.
Try assigning different random names to your source files (by renaming or copying) on each run
I'm looking for an possibility to call the Instagam application with Intent (like a Camera: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);) and pass to an external application a filter's tag, (as example tag #orchi).
Something similar to iphone hooks: http://instagram.com/developer/iphone-hooks/ or this one http://www.gramfeed.com/instagram/tags#orchi
On the official site is described an API but I need a simple solution to show images (filtered by tag) using an external Instagram application.