FaceBook dynamic Image URL - android

friend's,
I am working in Facebook,here i need to change the image url value string has dynamic one,
here my code
intent
.putExtra(
"attachment",
"{\"name\":\""
+ Html.fromHtml(title)
+ "\",\"href\":\""
+ Html.fromHtml(url_val)
+ "\",\"description\":\""
+ Html.fromHtml(desc_val)
+ "\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.naicu.edu/imgLib/20070913_small_seal.jpg\",\"href\":\"http://alumni.brown.edu/\"}]}");
this.startActivityForResult(intent, MESSAGEPUBLISHED);
here image source given in code has static,but i need to assign an simple string variable in the place of double quoted image url,for example
i want to place string temp_url in the place of **src\":\"http://www.naicu.edu/imgLib/20070913_small_seal.jpg**,how can i get it.
Thanks in advance.

Related

E-mailing a link gets terminated at a double quote in Android

I am working on an application that sends an e-mail with several information. Among the information is a link to the location of the user to Google Maps. A sample of the link would be:
http://www.google.com.ph/maps/place/14°39'3.8952"N121°2'57.4116"E/#14.651082,121.049281,17z
The code looks like this:
"Google Maps Link: http://www.google.com.ph/maps/place/" +
degToDMS(location.getLatitude()) + "\"N" +
degToDMS(location.getLongitude()) + "\"E/#" +
location.getLatitude() + "," + location.getLongitude() + ",17z");
I converted the degrees longitude and latitude to DMS using a formula I found online and it seemed to be returning good data. However, when I go check the email, the link looks like:
http://www.google.com.ph/maps/place/14°39'3.8952"N121°2'57.4116"E/#14.651082,121.049281,17z
and the hyperlink ends at the first double quote (") right before the N. This is actually a bit irritating and troubling because it doesn't link the entire link properly and it is cut.
How can I escape a double quote in a link? Or is there a better way to link to Google Maps?
I used URLEncode, thanks to for3st for the lead, as such:
final String urlRaw = degToDMS(location.getLatitude()) + "\"N" +
degToDMS(location.getLongitude()) + "\"E/#" +
location.getLatitude() + "," + location.getLongitude() + ",17z";
String encodedURL = "";
try {
encodedURL = URLEncoder.encode(urlRaw, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
where urlRaw is the "problematic' part of your url (where characters don't get escaped properly or something). You DON'T put in the http://.... because it will appear as such http%3A%2F%2Fwww.google.com.ph and yeah you don't want that.
Hence, I only escaped the latter part of my url, the one that starts with the DMS coordinates.
Once I have my encodedURL variable, I simply concat it to the rest of the starting URL as such:
String link = "Google Maps Link: http://www.google.com.ph/maps/place/" + encodedURL;
and not it works.

I Build a Brain Trainer app but Not Showing my TEXTVIEW when i run my app and warning is showing do not concatenate text display with setText

sumTextView.setText(Integer.toString(a) + " + " + Integer.toString(b));
This Line show warning you see in pic..
Use String.format();
sumTextView.setText(String.format("%1$d + %2$d", a, b));
With this you can format a string correctly with multiple variables, no matter whether they are strings or integers. This example takes the value of variable a and replaces the placeholder %1$d with it. Same goes for the other variable.
take an string copy whole line in it, then show string in setText
String str = (Integer.toString(a) + " + " + Integer.toString(a));
sumTextView.setText(str);
1. The First String Says that do not concate string with setText property.
String txt = String.valueOf(a) + " + " + String.valueOf(b);
sumTextView.setText(str);
2. Second warning says that your program have possibility to crash or genearte an exception in case if value of a or b is null or not an integer.
So check condition if(a!=null and b!=null) then display text in if condition.

Facebook API Error code 100 - Unity

I'm developing a game with Unity3D for Android. I'm using Facebook App for sharing game score in Facebook. But I receive a error message ;
My codes are here ;
//facebook share start
public static void share(string link, string pictureLink, string name,string caption, string description, string redirectUri){
Application.OpenURL(ShareUrl +
"?app_id=" + AppId +
"&link=" + WWW.EscapeURL( link )+
"&picture=" + WWW.EscapeURL(pictureLink) +
"&name=" + WWW.EscapeURL(name) +
"&caption=" + WWW.EscapeURL(caption) +
"&description=" + WWW.EscapeURL(description) +
"&redirect_uri=" + WWW.EscapeURL(redirectUri));
}//facebook share end
if(GUI.Button(new Rect(Screen.width/2,(Screen.height/2-30),80,20), "Share")){
print("Share");
share("http://www.halilcosgun.com","https://24.media.tumblr.com/avatar_ce3a5b939737_64.png","Facebook skor paylaşma denemesi " + score,"Skor da mı paylaşmıyah?","oyun çok yakında!","http://facebook.com");
}
I tried to write many adresses (many many configurations) intead of "http://facebook.com", but I can't find the true one.
If you know the solution, can you halp me please?
I would like to thank you for your interest.
there must me an invalid parameter that you have provided . try to find it out and make the change it will solve your issue
try the share with first s in caps example
Share("http://www.halilcosgun.com","https://24.media.tumblr.com/avatar_ce3a5b939737_64.png","Facebook skor paylaşma denemesi " + score,"Skor da mı paylaşmıyah?","oyun çok yakında!","http://facebook.com");
}

Android WebView Caching Issue

I am working on an Android application where I am using webview to display GIF files downloaded from internet, it is a picture viewer do user can click next and previous to view the next and previous gif files, the issue I am facing is that when user clicks next, for one split second it displays the older html and then updates the webview, I have tried disabling the webview cache but it is of no use, relevant part of the code is.
String base = Common.CACHE_IMAGES_PATH.getPath();
String imagePath = "file://" + base + "/" + forImage;
String html = "<html style=\"height:100%\"><head><META HTTP-EQUIV=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\"><META HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO-CACHE\"> </head><body style=\"padding:0x;margin:0px; background-color:#999;height:100%\"><img id=\""
+ System.currentTimeMillis()
+ "\" align=\"middle\" style=\"width:100%;height:auto;\" src=\""
+ imagePath + "\"></body></html>";
webView.loadDataWithBaseURL(Common.FULL_IMAGE_BASE_URL + forImage
+ "?fix=" + System.currentTimeMillis(), html, "text/html",
"utf-8", Common.FULL_IMAGE_BASE_URL + forImage + "?fix="
+ System.currentTimeMillis());
Here I am reading the image from sdcard and displaying it in webview, this code is executed everytime user click next or previous.

pass text to facebook wall on a button click android

I have to publish some text and image from a button on the xml layout, onclick of the button it will call an activity to share but how to pass text and images to face book through android.
please help me with an example.
probably through the facebook-api
Check this Code for Adding Image and Title in Facebook Post Wall :
String link ="www.google.com";
String image_url="http://dev.campusflock.com/img/medium_big_thumb/Deal/15.d23a69cbfb987be82dbfa563258080b9.jpg";
parameters.putString("method", "stream.publish");
parameters.putString(
"attachment",
"{\"name\":\""
+ "companyName"
+ "\",\"href\":\""
+ link
+ "\",\"description\":\""
+ "Title"
+ "\",\"media\":[{\"type\":\"image\",\"src\":\""+image_url+"\",\"href\":\"" +link+"\"}]}");
authenticatedFacebook.dialog(Main.this, "stream.publish",parameters, new TestUiServerListener());

Categories

Resources