Discussion Forums  >  WebViews and HTML for Mobile

Replies: 16    Views: 1277

perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
02/04/13 04:21 PM (11 years ago)

Link in html should open default browser in Android

When I load custom URL from server into app, a click on a normal <a href> link in that html should open the Android's default browser, according to Android docs. However, such links open in the app itself. Not good. How do I force normal html <a href> links to open in the Android browser? Is there a setting I'm overlooking?
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
02/04/13 05:09 PM (11 years ago)
Hi @perrytheweaver, You coding this? LA
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
02/04/13 05:38 PM (11 years ago)
Hey @perrytheweaver, Not positive about this but wouldn't the "Launch Native App" plugin work? LA
 
perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
like
02/04/13 05:52 PM (11 years ago)
can't use that plugin because i'm just reading html from a server, notcreating a new page to launch in native app.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/04/13 05:59 PM (11 years ago)
Have you tried something like <a href="that.distant.server.com" target="_blank">Here</a> ? or maybe 'target=_new' ? Cheers! -- Smug
 
perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
like
02/04/13 08:24 PM (11 years ago)
Yeah, I've added target="_blank" to the link, but does not change the behavior of the link. Still opens in the app, not the device's browser. There must be some config setting in the Android/Eclipse project that I'm missing...
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/04/13 08:34 PM (11 years ago)
I'm not sure if you're 'missing' anything... it's probably the natural behavior of the plugin... You may end up having to a) modify the existing plugin to accomodate external browser launching, or b) make a copy of the plugin, install it, and modify 'that' code so you don't mess up any other screens that rely on the 'natural' behavior. Either way, you'll probably end up with some modified code. Good luck on that, let us know if there is anything we can do! Cheers! -- Smug
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/04/13 08:40 PM (11 years ago)
Here is a link where David discusses how to launch an external browser from code: http://www.buzztouch.com/forum/thread.php?tid=DBAB2880AC563F1547B1886&currentPage=263 Here is a link where GoNorthWest explains a bit about the intrinsic 'document behavior' that might suit your needs... http://www.buzztouch.com/forum/thread.php?tid=DFF632D735503C5C3696310&currentPage=59 Cheers! -- Smug
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
02/04/13 09:24 PM (11 years ago)
Nice @Smug! LA
 
perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
like
02/05/13 08:45 AM (11 years ago)
Thanks, Smug! This looks very promising. You're a good egg :-)
 
perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
like
02/05/13 02:43 PM (11 years ago)
Okay, after much hair-pulling today, here is the file I modified in my Eclipse BZ project to force html links to load in mobile phone's native browser: /src/com/nameofyourprogramapp/BT_act_controller.java canLoadDocumentInWebView() Add a file type (or url snippet) to: doNotLoadList.add("facebook.com");
 
AlmaR
Lost but trying
Profile
Posts: 73
Reg: Jun 13, 2011
location unknow...
5,630
like
03/01/13 02:47 PM (11 years ago)
Wicked! Thanks a lot @perrytheweaver! I've had this problem for ages and I wasn't able to publish my Android app because of this. Getting ready to upload my app now!
 
perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
like
03/01/13 03:23 PM (11 years ago)
Great, AlmaR! Glad someone else could benefit from this!
 
AlmaR
Lost but trying
Profile
Posts: 73
Reg: Jun 13, 2011
location unknow...
5,630
like
03/01/13 06:22 PM (11 years ago)
Yeahh, thanks again! Do you know what we have in common, we have the same amount of posts (now I will have one more) and we registered almost the same day. Pretty weird, eh!?
 
AlmaR
Lost but trying
Profile
Posts: 73
Reg: Jun 13, 2011
location unknow...
5,630
like
01/21/14 06:41 AM (10 years ago)
Hi @perrytheweaver! Do you know where is the BT_act_controller.java or where to add these lines on BT v3.0? I added the following lines on BT_screen_customURL.java (not sure what exactly I am doing) and it works. When I click the link to youtube it launches youtube app but when I hit the back bottom the app crashes. Any suggestions? //not all documents load in the built-in webView.... public boolean canLoadDocumentInWebView(String theFileNameOrURL){ BT_debugger.showIt(currentURL (it was objectName in BT_act_controller.java but eclipse was doing an error and suggest this fix ) + ":canLoadDocumentInWebView \"" + theFileNameOrURL + "\""); boolean ret = true; if(theFileNameOrURL.length() > 1){ //this is a list of file types that cannot load in a webView, add types as needed. ArrayList<String> doNotLoadList = new ArrayList<String>(); doNotLoadList.add(".mp3"); doNotLoadList.add(".zip"); doNotLoadList.add(".doc"); doNotLoadList.add(".pdf"); doNotLoadList.add(".mpeg"); doNotLoadList.add(".mp4"); doNotLoadList.add(".xls"); doNotLoadList.add(".mov"); doNotLoadList.add("mailto"); doNotLoadList.add("tel"); doNotLoadList.add("yoube.com"); doNotLoadList.add("m.youtube.com"); doNotLoadList.add("youtu.be"); //is our localFileName valid? for(int x = 0; x < doNotLoadList.size(); x++){ if(theFileNameOrURL.contains(doNotLoadList.get(x))){ ret = false; break; } } } return ret; }
 
perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
like
01/21/14 12:56 PM (10 years ago)
Sorry @AlmaR, I don't have a clue!
 
AlmaR
Lost but trying
Profile
Posts: 73
Reg: Jun 13, 2011
location unknow...
5,630
like
01/21/14 05:35 PM (10 years ago)
Thanks for your reply @perrytheweaver! If I find out the fix and will post it over here. Have a good one!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.