Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 88

Rishav
Code is Art
Profile
Posts: 153
Reg: Jan 26, 2012
Dubai
8,780
06/30/13 01:39 PM (12 years ago)

Smug MsgLoc quick fix

Lately the MsgLoc plugin is not working properly on android. I suppose google maps url is redirecting the page or reloading and so we get a prompt to select a browser when we open the MsgLoc screen so here is a quick fix . Search for myMap.getSettings().setJavaScriptEnabled(true); just after it add the code(copied from CustomURL plugin) present below and it should start working again then. myMap.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url){ //remember the URL... smugmsgdata = url; //load the URL in the app's built-in browser if it's in our list of types to load... if(BT_act_controller.canLoadDocumentInWebView(url)){ //load url in built-in browser... showProgress(null, null); return false; }else{ //ask user what app to open this in if the method returned NO... try{ Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(Intent.createChooser(i, getString(R.string.openWithWhatApp))); }catch(Exception e){ BT_debugger.showIt(activityName + ": Error launching native app for url: " + url); showAlert(getString(R.string.noNativeAppTitle), getString(R.string.noNativeAppDescription)); } //do not try to load the URL.. return true; } } @Override public void onPageFinished(WebView view, String url){ hideProgress(); BT_debugger.showIt(activityName + ":onPageFinished finished Loading: " + url); } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { hideProgress(); myMap.loadUrl("about:blank"); showAlert(getString(R.string.errorTitle), getString(R.string.errorLoadingScreen)); BT_debugger.showIt(activityName = ":onReceivedError ERROR loading url: " + failingUrl + " Description: " + description); } });
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/30/13 03:44 PM (12 years ago)
Hey, thanks for this fix... Haven't been messing with Android lately and didn't notice. Much, much appreciated! Cheers! -- Smug
 
Rishav
Code is Art
Profile
Posts: 153
Reg: Jan 26, 2012
Dubai
8,780
like
07/01/13 12:20 AM (12 years ago)
The plugin is great and with a few modifications i made like detecting the city it works like a charm..
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
07/08/13 11:21 PM (12 years ago)
Following the above instructions resulted in several errors, the first of which is: Multiple markers at this line - WebViewClient cannot be resolved to a type - The method setWebViewClient(WebViewClient) in the type WebView is not applicable for the arguments (new WebViewClient(){}) Any ideas? Tim
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
07/09/13 06:35 AM (12 years ago)
Two additional things needed in Rishav's instructions to make that fix work: import android.webkit.WebViewClient; import android.net.Uri; Rishav, might want to add them in your post so when people look for the problem they see this too. Tim
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/09/13 01:43 PM (12 years ago)
Good to know. Thanks Tim :) Cheers! -- Smug
 

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.