after logged in ,remain in home_screen until logout <p>I want to send the username and password to the server and it returns a response whether the username and password matches. I do not want to ask for login each time my app starts, instead I want to remain in the <code>home_screen</code> until I logout from my android app. How can I do this? any example will be thankfull..</p> <pre><code>package com.example.test5; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.content.DialogInterface.OnClickListener; import android.os.AsyncTask; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends ActionBarActivity implements OnClickListener{ private EditText username; private EditText password; private Button login; static String u; static String p; Context context = MainActivity.this; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); username = (EditText)findViewById(R.id.editText1);//Visibility password = (EditText)findViewById(R.id.editText2);//Visibility login = (Button)findViewById(R.id.button1);//Visibility login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { u = username.getText().toString(); p = password.getText().toString(); Toast.makeText(MainActivity.this, "Checking User Login",Toast.LENGTH_SHORT).show(); new MyAsyncTask_Login(context).execute(u,p); } }); } @Override public void onClick(DialogInterface dialog, int which) { } } </code></pre> <hr> <p>my asynctask class</p> <pre><code>package com.example.test5; import java.io.StringReader; import java.util.LinkedList; import java.util.List; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserFactory; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.res.XmlResourceParser; import android.os.AsyncTask; import android.preference.PreferenceManager; import android.widget.Toast; public class MyAsyncTask_Login extends AsyncTask&lt;String, Void, String&gt;{ public static final String MyPREFERENCES = "MyPrefs" ; //editor: never used public static final String userName = "name"; public static final String Password = "password"; SharedPreferences sharedpreferences; //editor: never used private Context context; public MyAsyncTask_Login(Context context) { this.context = context; } @Override protected String doInBackground(String... params) { String response = new Login_WebService().checkLogin(params[0], params[1]); return response; } @Override protected void onPostExecute(String result) { String strResponse = result; try { XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser parser = factory.newPullParser(); parser.setInput(new StringReader(strResponse)); List&lt;String&gt; tags = new LinkedList&lt;String&gt;(); tags.add("valid"); for (int type = parser.next(); type != XmlResourceParser.END_DOCUMENT; type = parser.next()) { if (type == XmlResourceParser.START_TAG) { String name = parser.getName(); if (tags.contains(name)) { type = parser.next(); if (parser.getText().trim().equals("1")) { Toast.makeText(context, "logged in succesfully.",Toast.LENGTH_SHORT).show(); try { String user = MainActivity.u; String pass = MainActivity.p; Intent i = new Intent(context,Home_page.class); context.startActivity(i); } catch (Exception e) { Toast.makeText(context, e.toString(),Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(context, "Invalid User",Toast.LENGTH_SHORT).show(); } } } } } catch (Exception e) { } } } </code></pre>