这就是我想要做的,我有一个带有用户名和密码的android登录表单,在用户输入他的凭据并登录后,下一个表单应该显示在欢迎页面顶部,+从登录页面输入的用户名!但是如果用户重新访问了我的应用程序,那么消息应该是欢迎返回用户名,我怎么知道用户在我的应用程序中再次访问过?有人可以帮我吗?
我是android开发的新手,不知道该怎么做。感谢 public class HomeScreen extends Activity implements OnClickListener { String response = null;
public static HomeScreen object = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
object = this;
// String type = getResources().getString(R.string.TYPE);
// Logger.logger("mobile type :::::::::::: " + type);
// if (type.equalsIgnoreCase("mobile")) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// }
setContentView(R.layout.home);
findViewById(R.id.btn_call_us).setOnClickListener(this);
findViewById(R.id.btn_email_us).setOnClickListener(this);
findViewById(R.id.btn_panel_book).setOnClickListener(this);
findViewById(R.id.btn_get_instant_quote).setOnClickListener(this);
findViewById(R.id.btn_logout).setOnClickListener(this);
((TextView) findViewById(R.id.tv_welcome_msg_title)).setText("Welcome "
+ Comman.getPreference(HomeScreen.this, AppConstants.PRE_F_NAME, "") + "!");
new getJustInData().execute();
}
字符串响应;
@Override
protected String doInBackground(String... params) {
try {
response = HttpProcess.postDataOnServer(AppConstants.URL_WELCOME + "client="
+ Comman.getPreference(HomeScreen.this, AppConstants.PRE_COMPANY_NAME, ""));
Logger.logger("respons in welcome Message : " + response);
} catch (Exception e) {
response = "";
}
return "";
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
PDialog.dismiss();
String msg = Comman.getPreference(HomeScreen.this, AppConstants.PRE_WELCOME, "");
try {
String WelComeMsgResponseList = JsonParser.readWelcomeResponse(response);
if (WelComeMsgResponseList != null && WelComeMsgResponseList.length() > 0) {
Comman.setPreference(HomeScreen.this, AppConstants.PRE_WELCOME, WelComeMsgResponseList);
((WebView) findViewById(R.id.webview)).loadData("<font style='color:#ffffff;'><MARQUEE> "
+ WelComeMsgResponseList + " </MARQUEE></font>", "text/html", null);
((WebView) findViewById(R.id.webview)).setBackgroundColor(Color.BLACK);
return;
}
} catch (Exception e) {
} catch (Error e) {
}
((WebView) findViewById(R.id.webview)).loadData("<font style='color:#ffffff;'><MARQUEE> " + msg
+ " </MARQUEE></font>", "text/html", null);
((WebView) findViewById(R.id.webview)).setBackgroundColor(Color.BLACK);
}
}
}