Url link breaking up in text message Android Application - android

i have a url link am trying to send to my user, but the link breaks up cause. it sends the full link but about half of it is not underlined as a link. this is what am trying to send
String locateUrl="http://maps.google.com?q="+latitude()+","+longitude();
first it does not recognize this ?q= as a link and it just breaks up from there, have checked other answers and tried them but seems not to be working

Just solved this by putting "/" before ?q= thereby making sure the link doesn't break
full link will then be
String locateUrl="http://maps.google.com/?q="+latitude()+","+longitude();

Your link may be breaking because of space at the beginning or in between trim it and then use it.
String locateUrl="http://maps.google.com?q="+latitude()+","+longitude();
locateUrl = locateUrl.trim();

Related

Get Larger Image From Facebook Post?

I'm currently getting the newsfeed of a Facebook user. Currently, I can only retrieve thumbnail images that are associated with links, rather than the full-size image. Does anyone know how to get a larger image?
I've looked at the following posts and tried their solutions; however, the posts seem outdated and the facebook graph api seems to have changed since then:
Facebook Graph API Change: Picture type (size) no longer working?
Facebook API post: How to get larger thumbnail?
Please note that I'm on the me/home edge, so the answer below returns an error. See comments below.
my code is:
params.putString("fields","id,actions,application,caption,created_time,description,from,link,message,message_tags,"
+ "name,object_id,picture,place,source,status_type,story,updated_time,type,status_type,story,to,type,"
+ "updated_time,with_tags");
Change to this:
params.putString("fields","id,actions,application,caption,created_time,description,from,link,message,message_tags,"
+ "name,object_id,full_picture,place,source,status_type,story,updated_time,type,status_type,story,to,type,"
+ "updated_time,with_tags");
Here picture.height(1000) will give you a large image. and you can put your own required size but it is not supported in me/home i have searched a lot.
For Testing purposre use this link :Facebook graph explorer.
Eventually I came to this solution:
1) find the URL of the larger image (see code below)
2) get bitmap from URL and add to application UI.
The code mentioned above:
private String getRealURL(String smallURL){
if (smallURL.contains("url=http")){
String[] pieces = smallURL.split("url=");
pieces[1].replace("%2F", "//");
pieces[1].replace("%3A", ":");
Log.e("RealURL1:", pieces[1]);
return pieces[1];
}
else{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.setLength(0);
stringBuilder.append("https://graph.facebook.com/");
stringBuilder.append(item.getObjectID());
stringBuilder.append("/picture?type=normal&access_token=");
stringBuilder.append(Session.getActiveSession().getAccessToken());
Log.e("RealURL2:", stringBuilder.toString());
return stringBuilder.toString();
}
}
Simply use this field ?field=full_picture instead of picture.
?field=full_picture is the only way to get it to work now. I have been searching everywhere, and finally found the answer here. picture field doesn't support subfields any more so you can't use picture.width.height any more

How to get the link coordinates in EBookDroid of Android for opening the links programmatically

I'm developing a EBookreading application, EBookDroid is a library which we are using for the PDF reading. If we have any links in the PDF like www.stackoverflow.com, when the user clicks on it, it supposed to open the link, for that i need to find out the coordinates of that link in the Document.
I am writing like the below.
final RectF linkRect = page.getLinkSourceRect(pageBounds, link);
But it's always giving the null back.
Try this may be use full
THIS EXAMPLE

construct predefined messages with properties to post on Facebook android

I want to post a pre-defined message on Facebook through my android application. I got everything to work except the 'properties' field. I want to post a message where it says:
More information: here
and when the user clicks on 'here', it should link to the page.
This is what I did:
Bundle params = new Bundle();
String s2 = "{'More information':{'text':'here', 'href':" + details + "}}";
params.putString("properties", s2);
where 'details' is the link to the page.
But it seems like facebook is not picking up this line. I successfully set up the caption, picture and other fields.
Any insights? Thanks!
This is by design, as far as I know, we do not support HTML in status updates. We will automatically create a link if you post a valid URL however, so I would suggest just pasting out the full link
".....More information: (www.yourURLhere.com)"
On Facebook, www.yourURLhere.com will be a clickable link.

Android: Displaying a hyperlink and image inside email's body

I am trying to open email activity and to display in the email's body the following:
Display a hyperlink to a web site.
Display (not attach) an image logo (.png file).
I tried using html/text/image mime type and nothing works for both things.
I even tried to copy the png file to an sdcard and displaying it from sdcard path instead of using the "Assets" location that may be restricted and private only to the application, but it did not help as well!
Can anyone give me a code which works for both things??
Waiting for you help guys!!
Have you tried :
Linkify.addLinks(yourEmailString, Linkify.WEB_URLS);
yourTextView.setMovementMethod(LinkMovementMethod.getInstance());
It will make all links in the message clickable, not sure if this is what you are searching though :)?

Why is WebView unable to open some local URLs (Android)?

I have a WebView that I'm using to open some files stored in the assets/ directory of my project. It works fine for most of the files, but there's one in particular (and I'm sure others I haven't found) that it just will not open.
The file I'm having problems with is named:
"assets/ContentRoot/Photos/XXX Software Logo - jpg - 75%.JPG"
When I pass it to WebView, and it shows the error page, it shows it as:
"file:///android_asset/ContentRoot/Photos/XXX%20Software%20Logo%20-%20jpg%20-%2075%.JPG"
I then tried running URLEncoder.encode() on it and got the error page with the URL presented as:
"file:///android_asset/ContentRoot/Photos/XXX+Software+Logo+-+jpg+-+75%.JPG"
Neither of these URLs were able to open the file (and they both look okay to me). Anyone have any ideas?
UPDATE: If I encode the % by hand (using %25, as commonsware.com suggested) then it loads the image, but it tries to parse it as text, not as an image, so I just get a lot of (basically) garbage.
Also, referring to the image in an HTML document with a relative URL isn't working (probably because it's not being parsed as an image?):
<img src="../Photos/XXX%20Software%20Logo%20-%20jpg%20-%2075%.JPG" />
<img src="../Photos/XXX%20Software%20Logo%20-%20jpg%20-%2075%25.JPG" />
Okay, after spending way too long on this, I've figured out what's going on. Basically, if images stored in the assets/ directory contain a space (e.g., " ") in their file name, they won't render as images.
myWebView.loadUrl("file:///android_asset/testimage.jpg");
works fine. However,
myWebView.loadUrl("file:///android_asset/test+image.jpg");
just throws a not found error and
myWebView.loadUrl("file:///android_asset/test image.jpg");
// and
myWebView.loadUrl("file:///android_asset/test%20image.jpg");
show it improperly displayed (as text... see screenshot in question).
This unexpected behaviour is present on (at least) 1.5, 1.6, and 2.0 and I filed a bug report.
Try getting rid of the % in the filename. Or, escape it as %25.
I would guess that WebView only understands text related content types so it faithfully treating your JPG as base64 encoding, decodes and displays resulted gobble-goop as text. I don't really know if it's possible to set content type for WebView but as workaround you can try to throw img tag inside html tag and load resultet page. Also you probably can only use WebView#loadDataWithBaseUrl

Categories

Resources