Jump to content

URLRedirect on Android *SOLVED


RobYost

Recommended Posts

on my mobile app I have two menu items

 

1. Go to Full Site

UniSession.UrlRedirect(URL);

2. Logout (Which takes you to the login screen)

UniApplication.Restart;

Both of these work correctly on my phone while in a browser.

 

But when I created an android app that only has one component on it, a WebView

<WebView
android:id="@+id/activity_main_webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

They do nothing when clicked.  

 

I don't really know how WebView works, but it looks like I need to send something different to WebView to get it redirect.

 

 

Link to comment
Share on other sites

Add the two lines to MainActivity.java

package com.simple_landlord.simplelandlord;

import android.support.v7.app.ActionBarActivity;

import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;        ​<====Add this line

public class MainActivity extends ActionBarActivity {
  private WebView mWebView;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mWebView = (WebView) findViewById(R.id.activity_main_webview);
    WebSettings webSettings = mWebView.getSettings();
    mWebView.setInitialScale(1);
    mWebView.getSettings().setLoadWithOverviewMode(true);
    mWebView.getSettings().setUseWideViewPort(true);
    mWebView.getSettings().setJavaScriptEnabled(true);

    mWebView.setWebViewClient(new WebViewClient());   <====Add this line

    mWebView.loadUrl("https://secure.simple-landlord.com/m");
  }
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...