我希望该应用程序允许用户首次登录。然后,当用户退出应用程序而不注销时,即使用户再次启动应用程序,用户也将返回到登录布局之后的相同位置或布局。但是,如果用户从应用程序注销,用户将被带回主登录屏幕。
来自启动器(启动画面)----->(应用)登录页面--->(应用程序)主屏幕
来自家庭应用程序----->(应用程序)主屏幕
如果点击退出按钮
来自启动器(启动画面)----->(应用)登录页面--->(应用程序)主屏幕
My Splash screen code :----
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
public class splash_start extends Activity{
Handler handler = new Handler() {
};
protected void onCreate(Bundle var1) {
super.onCreate(var1);
this.setContentView(R.layout.splash);
Intend intend =new Intend (splash.this,login.class);
startactivity(intend)}
this.handler.sendEmptyMessageDelayed(0, 2000L);
}
}
my login.java code :----
public class log_inn extends Activity {
EditText uname, pass;
Button login;
String username, password;
String loginid;
ProgressDialog pDialog;
Intent in;
SharedPreferences sharedpreferences;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.log_in);
uname = (EditText) findViewById(R.id.editText1);
pass = (EditText) findViewById(R.id.editText2);
login = (Button) findViewById(R.id.button1);
if (android.os.Build.VERSION.SDK_INT > 8) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
}
pass.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
// TODO Auto-generated method stub
if (actionId == EditorInfo.IME_ACTION_DONE) {
login.performClick();
return true;
}
return false;
}
});
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
username = uname.getText().toString().trim();
password = pass.getText().toString().trim();
}
}