Facebook share image sharedialog - java

I'm sharing an image with my app, and the code is this:
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(Show.this)
.setDescription("xxxxxxxxxxxxxxxxxxxxxxxxx!")
.setApplicationName("appname")
.setPlace("me/photos/")
.setPicture(imagesURL+imageFileName)
.setLink("https://play.google.com/store/apps/details?id=x.x.xxx")
.build();
everything is fine, but the image is getting shared small-sized on the side of the link, and not into the user's profile, what should i do to share it like a normal "big" photo?
Also, if i take the
.setLink(xxxxxxxxxxxx);
the image isn't shared at all..

What I think is that in your setLink() function you are giving the link of the page not the image resource.
For example if you have an image link like this .
http://blog.delicious.com/wp-content/uploads/2013/07/facebook_logo.jpg
now as this is the link to the image resource on the server, If you use it in the setlink function
setLink("http://blog.delicious.com/wp-content/uploads/2013/07/facebook_logo.jpg");
You will get the big Image.

Related

Showing the video of the link shared on Whatsapp for Android Java or kotlin on Whatsapp

Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, videoLink);
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
I can send the link containing the video to someone on WhatsApp, however, I want to show the image of the video to the user on WhatsApp.
Is there a way to do this in java or kotlin
as in the picture
I am not sure what you're trying to do exactly but there are two options I can think of.
Firstly, if you're looking for something like what you have in the screenshot then no coding is required.
This is usually handled by Facebook when their bot scrapes the meta tags from the page that is shared.
If you wanted to accelerate this process you can manually put the link that you want to share in Facebook's Sharing Debugger and scrape it manually so that Facebook takes note of it.
Once that is done you can share the link and it should display video information including the image, title & description.
However, if you want to share only the video image/thumbnail you can do that as follows:
grab the video ID from the URL using REGEX or by taking a substring of the URL that holds the ID.
Plug that ID in one of the following URLs to get a link to an image that you can share instead of the video.
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/default.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/sddefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
Thanks to #asaph for his details answer on getting Youtube thumbnail here

Is there any option for Glide if url is changed then cache will be cleared otherwise load with old image?

i am using glide for showing loading images, and in my app image will be changed frequently, is there any option for clear cache when new image or image will be edited otherwise load old one?
try this:
whenever image changes the cache will remove
Glide.with(YourActivity.this)
.load(Uri.parse(image_url))
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.into(mImage);
refer this link hope it will help you to resolve this issue
I have used the below code to achieve the same that you have mentioned in the description above.
fun ImageView.loadUrl(url: String) {
var requestOptions = RequestOptions()
requestOptions.signature(ObjectKey(System.currentTimeMillis()))
Glide.with(this).load(url).apply(requestOptions).into(this)
}
It's just an extension for the imageview and you need to use below way wherever you want this in your app.
imageView.loadUrl(url)

Programmatically get like count of a photo from Facebook using java

I am developing an andorid app which post some photo on Facebook, at the same time I want to calculate the number of likes of that photo from my android app.
For information -
I am using Facebook SDK and I have successfully logged in Facebook account and posted the image.
The method which post image is below
private void PublishImage()
{
Bitmap image = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher);
//Here we set all the required parameters to share the image and build that
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.setCaption("Testing Sharing Feature through java")
.build();
//Now we share the PhotoContent by adding the properties in instance of SharePhotoContent
share = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
//Now we use share API to share the image
ShareApi.share(share,null);
}
How to calculate the number of likes of posted photo with java instead of using Graph API Explorer manually ?
I don't think you can do that without the graph API. Once you call ShareApi.share (), there is actually a graph API request which uploads the photo, and you will get likes from various platforms, your app has no way of knowing how many likes have been posted

Share an image and tag some people in a Android App to google plus from inside the code

I'm creating an Android App that shares an image or a text in your google plus profile. I need to tag some people from inside the code with the function -> .setRecipients(recipients). I succeeded to share an image in google plus or share an text tagging some people from inside the code. But i couldn't do both of them, i tryed to share an image and tag people from inside the code, but when i share the image with function addStream(myUri), the function setRecipients(recipients) stop working. If i comment the addStream(), the setRecipients() works fine but don't shares the image. I tryed to change the setType to "video/, image/" or "image/jpeg", but nothing. Any suggestions?
ArrayList<Person> recipients = new ArrayList<>();
recipients.add(PlusShare.createPerson("106189723444098348646","Larry Page"));
recipients.add(PlusShare.createPerson("109813896768294978296","Sergey Brin"));
Uri myUri = Uri.parse("content://media/external/images/media/10222");
Intent shareIntent = new PlusShare.Builder(this)
.setType("text/plain")
.setText("Sharing in google plus!")
.setRecipients(recipients)
//.addStream(myUri)
.getIntent();
startActivityForResult(shareIntent, 0);

Display Video thumbnails from URL

Okay this might be a stupid one but kindly pardon me because I'm new to Android. I'm working on an App in which I want to display video thumbnails using remote URL's like:
Video URL:
http://173.193.24.66/~kanz/video/flv/9.flv
.JPG URL:
http://173.193.24.66/~kanz/video/Images/9.jpg
I have got both the video URL's and Image File URL's that I want to display on thumbnails stored on SQL database. The only thing is I don't know how to put them in List view inside a ScrollView. I tried searching on the Internet but they all seem to give tutorials on how to display video thumbnails from sd card path. I want to use any of these URL's to display video thumbnails.
I heard about API's but I can't use Youtube API since Youtube is banned in my country. If anyone knows any useful API or any other hack around, let me know. It would be highly appreciated. I'm using Gingerbread.
Add these lines to your Module:app gradle:
dependencies {
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
// pass video url into .load() method
Glide.with(context)
.asBitmap()
.load(/*Video Url*/)
.into(/*Name of Imageview*/);
Listview has its own scroll. So do not put listview inside a scroll view.
Use a custom listview to display the thumbnail.
Get your urls form the database.
http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/
http://www.youtube.com/watch?v=wDBM6wVEO70. The talk is about listview and performance.
Use a viewholder.http://developer.android.com/training/improving-layouts/smooth-scrolling.html.
If you are displaying lot of images in listview consider using one of the below libraries.
1.Universal Image loader. https://github.com/nostra13/Android-Universal-Image-Loader.
2.Lazy List. https://github.com/thest1/LazyList.
Both use caching.
For univarsal Image Loader
In your adapter constructor
File cacheDir = StorageUtils.getOwnCacheDirectory(a, "UniversalImageLoader/Cache");
imageLoader = ImageLoader.getInstance();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(a)
// You can pass your own memory cache implementation
.discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation
.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
.enableLogging()
.build();
// Initialize ImageLoader with created configuration. Do it once.
imageLoader.init(config);
options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.stub_id)//dummy image
.cacheInMemory()
.cacheOnDisc()
.displayer(new RoundedBitmapDisplayer(20))
.build();
In your getview()
ImageView image=(ImageView)vi.findViewById(R.id.imageview);
imageLoader.displayImage(imageurl, image,options);
Those tutorials are correct but you're missing a step. You need to download these images to the device first using the URL. Then you can set them up to be viewed in a listview.
See how to do this in these threads:
How to load an ImageView by URL in Android?
Android, Make an image at a URL equal to ImageView's image
There is a popular open source library that handles downloading and caching of images automatically. Check it out:
https://github.com/koush/UrlImageViewHelper

Categories

Resources