Posting to Facebook Via Android Does not Show Image - java

I am trying to implement the Facebook share functionality in my app but when I click on the share button I get the following image:
Here's the code that I am using:
ShareDialog shareDialog = new ShareDialog(ResultsActivity.this);
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setQuote("Hi Guys, I have completed Level " + level + " and I scored " + score + ". Can you beat my score?")
.setContentUrl( Uri.parse("http://play.google.com/store/apps/details?id="
+ getPackageName()))
.build();
shareDialog.show(linkContent);
}
The google play link works fine and it has icon image and the necessary images.
When I was browsing for solution online, I found that Facebook OpenGraph Debugger helps in determining the cause. So, I used this link to look for any causes and Facebook was complaining about missing og:type as shown below:
What code should I add in android studio in order to fix this problem? Any help or suggestion will be greatly appreciated.

Ok, so the image finally appeared. I had to give it at least 6 hours for the image to appear. All I did was go back to the Facebook debugger link, and refresh my play store link and it showed me a preview with the image.
So if anyone is facing the same issue, please be patient. :)

Related

Convert Android view to PDF of A4 size

I have an android resume building application. I want to generate a PDF of size A4 from my view. Here's how my layout looks like - At the top I have a Top App Bar, and the whole view in encapsulated in drawer. The main part which contains user's details is encapsulated in nestedScrollView, which contains multiple LinearLayout and TextView. In this screenshot below, I have populated it with mock data, but in actuality, I am fetching data from the Firebase Realtime Database and displaying it on the UI.
I tried to understand iTextPdf solution and multiple question of similar type that has been asked here, but I couldn't find something solid. Please help me out, it would be of great help.
Also, please don't close this question by giving a reason that the question doesn't contain any code. It doesn't because I don't have any. I am trying to solve this problem from scratch. I have tried to describe my problem as much as I could.
try this:
create a WebView and copy the text of your edittext in it:
webview.loadData(youredittext.gettext().tostring, "text/html", "UTF-8");
and convert webview to pdf by below function:
private void createWebPrintJob(WebView webView) {
PrintManager printManager = (PrintManager) this
.getSystemService(Context.PRINT_SERVICE);
PrintDocumentAdapter printAdapter =
webView.createPrintDocumentAdapter();
String jobName = getString(R.string.app_name) + " Print Test";
if (printManager != null) {
printManager.print(jobName, printAdapter,
new PrintAttributes.Builder().build());
}
}
after that user can select page size for example A4
There are a lot of libraries that convert layouts to PDF, but let's opt for popular one so we could find answers if we're stuck.
The libraries I listed works like so : They take screenshot of your layout as bitmap image and convert it to pdf.
- 1st solution: iTextPDF https://github.com/itext/itext7 (New Version).
check this detailed tutorial which treates also the case of taking screenshot of a scrollview https://www.codeproject.com/Articles/989236/How-to-Convert-Android-View-to-PDF-2
and this stackoverflow answer https://stackoverflow.com/a/29731275/12802591
- 2nd solution: PdfMyXML library https://github.com/HendrixString/Android-PdfMyXml just follow the steps in the documentation.
They may be other solutions, but these are the popular ones.
Let Me know if it works for you and also if you're stuck. Thank you!

Not able to use INTENT_VIEW in android pie it 's showing nothing

I am making an application which uses intent to call all the application in the device with UPI. My code works fine before Android Pie but, in android pie it's showing nothing.
Here is my code:
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(upi_link));
Intent chooser = Intent.createChooser(intent,getString(R.string.payupitext));
startActivityForResult(chooser, 1, null);
I want to know if there is any update in the which i have to put,I have searched but found nothing.If anyone can help i would be extremely grateful.
Thanks

How to change a photo?

I am trying to change photos in android studio by clicking on my button.
When I put code for changing the photo in my MainActivity.java I keep getting this type of error messages and it says :
Cannot resolve symbol "image"
image.setImageResource(R.drawable.xxx);
I am watching Udemy course for android development and I have done everything same like the professor on that video.
I have tried to restart android studio.
I have tried to make new project.
I have tried to clear invalidate caches and restart.
public void changeImage(View view)
{
ImageView bitcoin = findViewById(R.id.bitcoin);
image.setImageResource(R.drawable.xxx);
}
I hope there is actual error with android studio,because code is clone of the video that I am watching.
You are binding your layout's ImageView in Java file with bitcoin variable and you are trying to set an image on an unknown variable 'image'(maybe it's not defined in the class). So you have to set as below.
ImageView bitcoin = findViewById(R.id.bitcoin);
bitcoin.setImageResource(R.drawable.xxx);
Set Your Code Like this
ImageView image = findViewById(R.id.bitcoin);
image.setImageResource(R.drawable.xxx);
change your this line
image.setImageResource(R.drawable.xxx)
to this one:
bitcoin.setImageResource(R.drawable.xxx)

Facebook4j post picture with caption text

I'm new to Facebook4j and I want to sync my blog with Facebook And Twitter? The main idea is, everytime a new post is publised, a picture is simultaneously posted on social media, with an image and a caption (containing a link).
I've used this snippet for Facebook4, but it does not seem to be working. Picture is posted, but no caption is added to it !!
Media media = new Media(notificationPicture);
photoUpdate = new PhotoUpdate(media);
photoUpdate.setMessage(notificationCaption);
facebook.postPhoto(media);
Could you please tell what's wrong or missing with this snippet ?
Thank you very much.

FriendPickerSample doesn't show my friends

I am testing this sample from the Facebook SDK, but don't appear any friends... it says: " "
When I click Pick Friends, a pop up window shows:
" FriendPickerSample would like to access your public profile and friend list"
And I click "OK", but nothing happens it keeps showing only the string ""
Do you guys have any clue?
Problem solved, I didn't had the key hash registed on facebook app developer, neither had the app_id on the strings xml file.
Thanks all anyways

Categories