Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: unable to maintain session after logging in the application
    primarykey
    data
    text
    <p>I am trying to open up a URL in <code>WebView</code> but i am unable to do so and i think that is because the session is not maintained. I am sending the username, password and the id of user to the server in an activity. here's the code ..</p> <pre><code>public class ServiceActivity extends Activity { private Button button_back; private Button button_submit_user_pass; private EditText edit_id_code; private String contents; private String format; private String username; private String password; private String id; public static HttpClient client; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.qr_code_view); edit_id_code = (EditText) findViewById(R.id.editText_id); button_back = (Button) findViewById(R.id.button_back); button_submit_user_pass = (Button) findViewById(R.id.button_submit_user_pass); Intent user_pass = getIntent(); username = user_pass.getStringExtra("user"); password = user_pass.getStringExtra("pass"); button_submit_user_pass .setOnClickListener(user_pass_qr_submit_listener); button_back.setOnClickListener(back_listener); } private View.OnClickListener user_pass_qr_submit_listener = new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub try { id = edit_id_code.getText().toString(); client = new DefaultHttpClient(); HttpPost post1 = new HttpPost( "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); List&lt;NameValuePair&gt; nvp = new ArrayList&lt;NameValuePair&gt;(); nvp.add(new BasicNameValuePair("uname", username)); nvp.add(new BasicNameValuePair("password", password)); nvp.add(new BasicNameValuePair("id", id)); post1.setEntity(new UrlEncodedFormEntity(nvp)); HttpResponse resp = client.execute(post1); String responseText = inputStreamTOString( resp.getEntity().getContent()).toString(); Log.i("response", responseText); int num = Integer.parseInt(responseText); if (num == 0) { Toast.makeText(getApplicationContext(), "Response" + responseText, 0).show(); } else if (num == 1) { Intent survey = new Intent(ServiceActivity.this, WebViewActivity.class); startActivity(survey); } } catch (Exception e) { Log.e("error", "ERROR" + e); } } }; private View.OnClickListener back_listener = new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub } }; private StringBuilder inputStreamTOString(InputStream is) { String line = ""; StringBuilder total = new StringBuilder(); // read response until the end try { BufferedReader rd = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8); while ((line = rd.readLine()) != null) { total.append(line); } } catch (Exception e) { // TODO: handle exception } return total; } } </code></pre> <p>After this if the response from the server side is "1" i am opening a new activity in which I need to display the content of the user in the <code>WebView</code> here's the code</p> <pre><code>public class WebViewActivity extends Activity{ private WebView web; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.web_view); web = (WebView) findViewById(R.id.webView); web.getSettings().setJavaScriptEnabled(true); web.loadUrl("xxxxxxxxxxxxxxxxxxxxxxxxxxxx"); } } </code></pre> <p>but i am unable to load the URL corresponding o the user, I get php errors over the webviewactivity and that is because i am unable to maintain the session of the user who has logged in. Please suggest me some solution to this. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload