[英]Check if is user first login on Android App using Firebase Auth and Database
[英]Android Login and pasting first and secondnames to user area
大家好,我需要您的帮助,我被困在那个地方。 我希望将名字和第二名粘贴到用户区域以在登录后自动出现。问题是用户区域与登录活动后的下一个区域不在同一个Java类中。
这是登录活动中的代码部分
if(session.loggedin()){
startActivity(new Intent(LoginActivity.this, MainActivity.class));
finish();
}
btnlogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final String email = etemail.getText().toString();
final String password = etpassword.getText().toString();
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if(success){
String firstusername = jsonResponse.getString("firstusername");
String secondusername = jsonResponse.getString("secondusername");
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra("firstusername", firstusername);
intent.putExtra("secondusername", secondusername);
startActivity(intent);
finish();
session.SetLoggedIn(true);
这是来自用户活动的代码
/*
Code for showing users name and last name
*/
final TextView firstUsername = (TextView) findViewById(R.id.firstusername);
final TextView secondUsername = (TextView) findViewById(R.id.secondusername);
Intent intent = getIntent();
String firstusername = intent.getStringExtra("firstusername");
String secondusername = intent.getStringExtra("secondusername");
firstUsername.setText(firstusername);
secondUsername.setText(secondusername);
现在,我上传了更多代码。
您的方法似乎正确。 首先,您应该检查您的临时演员是否不为空(由于某种原因)。 捆绑包= getIntent()。getExtras(); 如果(extras!= null)
或者,如果您传递给intent的变量(从json反序列化的变量)不为空
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.