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
Related
I need to display the YouTube's video thumbnail image for every video searched or featured. I just need the syntax and method to implement it in my java swing application.
You can load the thumbnails directly via web request. Take a look at How do I get a YouTube video thumbnail from the YouTube API?
EDIT
Here are some sample links:
https://img.youtube.com/vi/<video-id>/default.jpg
https://img.youtube.com/vi/<video-id>/hqdefault.jpg
- or -
https://img.youtube.com/vi/<video-id>/maxresdefault.jpg
Assuming you get the SearchListResponse from youtube v3 data api. Now you can easily fetch the thumb url using following code.
SearchListResponse response = // data fetched from yt data api.
java.util.List<SearchResult> searchResultList = response.getItems();
for (SearchResult sr : searchResultList) {
String thumburl = sr.getSnippet().getThumbnails().getDefault().getUrl();
//for high resolution you can use: sr.getSnippet().getThumbnails().getHigh().getUrl();
}
related links. https://developers.google.com/youtube/v3/docs/search/list
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);
I am creating an android app that have some page with information read from the sqlite database and a qr code reader built in the app, but i have question to ask
This is my question :
when i read the qr code which contain some IDs, is it possible to link/bring to a particular page that have that IDs ?
I try to google for information about this, but i did not find any sample code or tutorial that teach how to link from qr code to particular part in the android app. From all the google information i found, i only know that i need a url, then how can i generate a url to link to the android app? does it mean that i have to create a website?
MY MAIN IDEA:
in my android app have information:
Page 1:
Apple
cost 1 dollar
Page 2:
Pear
cost 1.50 dollar
What i want to do:
Scan qr code from my android, reader retrieve Page 1 as ID, then link/go to Page 1 in the android app
I just want go to or link to that particular activity1(page1) after scan the qr code that contain 1 within that same app
To open url from android app use this:
String url = "http://www.example.com/YOUR-ID-GENERATED_PAGE";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
source page here on StackOverflow
You can use TEXT format of QR code to return a text rather than a URL. In your case, the returned text could be an ID. Map your IDs with the Activities you are intended to awake after scanning.Then check the ID and start your mapped Activity manually in your application.
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.
Android platform is really fun to work with especially when it comes to resolving issues. Indeed, there is possibly everything there is to know about Android development on the internet.
Alright, I've been searching for about a week and haven't found anything that was close from working. Let's dive into it.
We are building an Android Application that requires a read/write access to existing Contacts on a device. It has become really easy to read a contact's set photo using this method :
// Returns a stream reading a contact thumbnail
public InputStream getContactThumbnail(int id) {
// Stream reading contact image
InputStream stream = ContactsContract.Contacts.openContactPhotoInputStream(
context.getContentResolver(),
ContentUris.withAppendedId(
ContactsContract.Contacts.CONTENT_URI, id
)
);
// If image is null, try to read Facebook image
if (stream == null) {
stream = new ByteArrayInputStream(getFacebookPhoto(id));
}
return stream;
}
Now, the previous method receives an id as a parameter and returns a Stream making it possible to read the contact's thumbnail. It is needed to be a stream because the phone acts like a web server and has multiple threads running. If a thumbnail is requested several times in the same short time lapse, an OutOfMemoryException will be thrown for sure.
I need to correctly implement the getFacebookPhoto(int) method so that it returns whatever stream reading the Facebook profile picture of a contact that has his or her contact linked with his or her respective Facebook profile. I've tried and failed so many times.
Hypothesis #1
If a contact is linked with a Facebook profile, it has to have the Facebook ID saved somewhere. If this information is accessible, it would make it easy to get a Facebook profile picture using graph. Problem is an internet connection is needed to do so.
Hypothesis #2
Facebook thumbnails are saved somewhere on the SD card. Maybe there's a link between a Contact and those files that can be found through an SQLite request?
Hypothesis #3
sigh, I look desperate. Okay, if I understood correctly, a phone Contact and a Facebook Contact are not the same things in the database. If you query all the contacts from the following URI :
*ContactsContract.Contacts.CONTENT_URI*
you only get contacts that you created and nothing regarding Facebook links. Is there a way to find all linked contacts and get their respective photos?
Conclusion
Yeah, that's about is. To sum it up, I need to read all contacts information. For each contact, I have to find its photo. If the user has not set a picture to a contact that is linked to a Facebook profile, the profile picture which it was linked too must be read.
Up until now, the StackOverflow community has been of a great help and saved my life and job countless times. It is possible, I've seen it in other apps.
Thank you for spending of your time, it is truly appreciated.
EDIT
Let's not give up! I will start a 100pts bounty as soon as I can.
Your hypothesises are right to a certain extend. In contact application this things are handled as folows -
Device's Contact & its Facebook account are mapped by Contact's _ID & Facebook's id, this is one-to-one mapping. So from this mapping first you have to find out the Facebook id
of the conserned contact. But in which table this info is stored & wheather that table is eposed to you or not, URL to that table completely dependent on vendors.
From Facebook Id we can get corresponding profile image either from Facebook's server or from Media DB, if it is also cached in.
But this is not supported by all OEMs. And implementation varies from OEM to OEM as Google don't enforce for any common standard implementation of it.
So there is no garantee that a single implementation will work for all devices from different OEMs.
You should really go and play around with Graph Explorer on the Facebook Developers site it will help you a lot in figuring out what you need to do to get certain things. In order to get the picture for an person you just have to do is do a simple GET HTTPRequest with the graph path of /ID?fields=picture (where ID is the facebook id of the contact) which will return a JSON object that contains the link to that person's profile picture. From there it should be fairly simple for you to get the image.
You can also do the same thing to get all of a person's friends with the picture information by sending a GET request to /me/friends?fields=picture. It seems like you are trying to avoid a web connection but if the android contacts do not store the facebook id then you will have to get the ids yourself I'm afraid.
Hope that helps.
Why don't you use FQL, for Android you can use -
String query = "SELECT uid, name, pic, pic_small, pic_big FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";
Bundle params = new Bundle();
params.putString("method", "fql.query");
params.putString("query", query);
mAsyncFacebookRunner.request(null, params, new CustomRequestListener());
where CustomRequestListener() extends RequestListener in the Facebook Android SDK.