So, I've been Googleing around for 4 hours now :( and i cant get the website to only stay opened in the app. After you type in the username and password upon clicking log in the page opens in the default browser. What I learned is, I should use: shouldOverrideUrlLoading()
but I don't know where place it and how to use it to. This is my MainActivity.java
, where or what do I put in there to stop it from opening in the default browser.(ignore the *)
package com.example.***.*******c;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends Activity {
private WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.*******.org/");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
You have to implement a class that extends WebViewClient and override it in there. Try this: