Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class getlogindetails extends AsyncTask<String,String,String>
- {
- protected void onPreExecute()
- {
- super.onPreExecute();
- pdialog=new ProgressDialog(loginactivity.this);
- pdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
- pdialog.setMessage("Logging in. Please wait...");
- pdialog.setIndeterminate(false);
- pdialog.setCancelable(true);
- pdialog.show();
- }
- @Override
- protected String doInBackground(String... params)
- {
- int success;
- try
- {
- Uri.Builder builder=new Uri.Builder()
- .appendQueryParameter("username",username)
- .appendQueryParameter("password",password);
- String query=builder.build().getEncodedQuery();
- JSONObject json=jsonParser.makeHttpRequest(urllogin,query);
- if(json!=null)
- {
- success=json.getInt("result");
- if(success==1)
- {
- Intent menuintent=new Intent(getApplicationContext(),menuactivity.class);
- startActivity(menuintent);
- }
- else
- {
- loginactivity.this.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- tmsg.setText("User not found !");
- tmsg.setTextColor(Color.RED);
- }
- });
- }
- }
- else
- {
- loginactivity.this.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- tmsg.setText("Unable to contact server !");
- tmsg.setTextColor(Color.RED);
- }
- });
- }
- }
- catch(JSONException e)
- {
- e.printStackTrace();
- }
- return null;
- }
- protected void onPostExecute(String s)
- {
- pdialog.dismiss();
- }
- }
- username=tusername.getText().toString();
- password=tpassword.getText().toString();
- urllogin="http://10.3.5.59/iverson/loginprocess.php";
- new getlogindetails().execute();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement