I have a webview that is working perfectly as follows:
wv = (WebView) findViewById(R.id.wv);
//Enable JavaScript
wv.getSettings().setJavaScriptEnabled(true);
wv.setFocusable(true);
wv.setFocusableInTouchMode(true);
//Set Render Priority To High
wv.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
wv.getSettings().setDomStorageEnabled(true);
wv.getSettings().setDatabaseEnabled(true);
wv.getSettings().setAppCacheEnabled(true);
wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
//Load Url
wv.loadUrl("https://str8red.com/");
I then have the following code which runs when a button is clicked:
button.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
final RequestQueue requestQueue = Volley.newRequestQueue(MainActivity.this);
StringRequest stringRequest = new StringRequest(Request.Method.GET,"https://str8red.com/loggedincheck",
new Response.Listener<String>(){
@Override
public void onResponse(String response) {
textView.setText(response);
requestQueue.stop();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
textView.setText("Something went wrong");
error.printStackTrace();
requestQueue.stop();
}
});
requestQueue.add(stringRequest);
}
});
The address simply returns a string of "True" or "False" depending if the user is logged into the webview. The good news is that it is returning a string but it is always returning False, even when I have logged in to my site using the webview. I know the address https://str8red.com/loggedincheck
works as expected as it works both in a web browser and also in the iOS app.
I am assuming that when the button is clicked it is not using the the same webview and therefore has no idea if the user is logged in or not.
I have looked online for a solution but have come unstuck. Any help would be appreciated.
If you need any additional information please do not hesitate to ask.