Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>doInBackground</code> runs in a worker thread which cannot do any UI work</p> <p>Please update LoginActivity.java</p> <pre><code>public class LoginActivity extends Activity implements OnClickListener { Button btnLogin; Button btnLinkToRegister; EditText inputEmail; EditText inputPassword; TextView loginErrorMsg; private EditText user, pass; private Button mSubmit, mRegister; // Progress Dialog private ProgressDialog pDialog; // JSON parser class JSONParser jsonParser = new JSONParser(); // JSONObject output JSONObject json=null; // php login script location: // localhost : // testing on your device // put your local ip instead, on windows, run CMD &gt; ipconfig // or in mac's terminal type ifconfig and look for the ip under en0 or en1 // private static final String LOGIN_URL = // "http://xxx.xxx.x.x:1234/webservice/login.php"; // testing on Emulator: private static final String LOGIN_URL = "http://www.google.com/login.php"; // above url has been changed private static final String TAG_SUCCESS = "success"; private static final String TAG_MESSAGE = "message"; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.main); // Importing all assets like buttons, text fields inputEmail = (EditText) findViewById(R.id.et_user); inputPassword = (EditText) findViewById(R.id.et_pw); mSubmit = (Button) findViewById(R.id.btn_login); mRegister = (Button) findViewById(R.id.btn_reg); loginErrorMsg = (TextView) findViewById(R.id.login_error); mSubmit.setOnClickListener(this); mRegister.setOnClickListener(this); } @Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.btn_login: new AttemptLogin().execute(); break; case R.id.btn_reg: Intent i = new Intent(this, RegisterActivity.class); startActivity(i); break; default: break; } } class AttemptLogin extends AsyncTask&lt;String, String, String&gt; { /** * Before starting background thread Show Progress Dialog * */ boolean failure = false; @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(LoginActivity.this); pDialog.setMessage("Attempting login..."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.show(); } @Override protected String doInBackground(String... args) { // TODO Auto-generated method stub // Check for success tag int success; String username = inputEmail.getText().toString(); String password = inputPassword.getText().toString(); try { // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("username", username)); params.add(new BasicNameValuePair("password", password)); Log.d("request!", "starting"); // getting product details by making HTTP request json = jsonParser.makeHttpRequest(LOGIN_URL, "POST", params); // check your log for json response Log.d("Login attempt", json.toString()); // json success tag success = json.getInt(TAG_SUCCESS); if (success == 1) { return "success"; } } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(String file_url) { // dismiss the dialog once product deleted pDialog.dismiss(); if (file_url != null &amp;&amp; file_url.equals("success")) { Intent i = new Intent(LoginActivity.this, Myidealmain.class); finish(); startActivity(i); } } } } </code></pre>
    singulars
    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.
    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