0

I have a web application with login credentials. I am loading this web application in Android WebView. It is working fine. The problem is, after application close and click on my application launcher icon in my tab it always showing login page. But I dont want login page, once I logged in and close my apllication and click launcher icon, I want to open directly after logged in page.

Here is my code:

public class MyActivity extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

    try {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        WebView webview = (WebView)findViewById(R.id.webview);

        WebSettings settings = webview.getSettings();  
        settings.setSupportMultipleWindows(true);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);

        webview.getSettings().setJavaScriptEnabled(true);
        webview.setWebViewClient(new WebViewClient() {

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });

        webview.loadUrl("http://192.1xx.x.xxx:8280/login.jsp");
    } catch(Exception e) {
    }
}
  • After you got login successfully, you can save credentials in shared preferences. Check your credentials before login. see my post http://stackoverflow.com/questions/12639899/shared-preferences-in-android/12640072#12640072 this might be helpful . – Akhilesh Mani Mar 05 '13 at 07:24

1 Answers1

1

Do one thing just save the second page (The page after login) in the prefrances when you load the App first time and save the Login status in the prefrance and after that second time you can check the status if it is yes then call the page you had save into the prefrance if not open the Login page.

Here is the code for save the page:

WebViewClient yourWebClient = new WebViewClient()
            {    
                /* Override page so it's load on my view only */
                @Override
                public boolean shouldOverrideUrlLoading(WebView  view, String  url)
                {
return true;

                }
Amandeep singh
  • 1,865
  • 7
  • 21
  • 41