我正在使用改造库我想在登录屏幕上调用所有数据,如果登录成功,则通过相同的getter setter在下一个活动中显示数据。这可能吗?
public void onResponse(Call<TaskResponse> call, Response<TaskResponse> response)
{
int statusCode = response.code();
String checking = String.valueOf(response.body().getCode());
if (checking.equals("0"))
Toast.makeText(getApplicationContext(),"Invalid username or Password",Toast.LENGTH_LONG).show();
else if (checking.equals("2"))
Toast.makeText(getApplicationContext(),"Invalid Company Code",Toast.LENGTH_LONG).show();
else if (checking.equals("1")) {
Toast.makeText(getApplicationContext(), "Login Successful", Toast.LENGTH_SHORT).show();
List<Task> test;
test = new ArrayList<Task>();
test = response.body().getTasks();
Intent intent = new Intent(LoginActivity.this, EmpTaskActivity.class);
intent.putParcelableArrayListExtra("test", (ArrayList<? extends Parcelable>) test);
startActivity(intent);
}
// recyclerView.setAdapter(new MoviesAdapter(movies, R.layout.list_item_movie, getApplicationContext()));
}
登录成功时(在您的LoginActivity中)。
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra("DESIRE_KEY",loginModelUsedToCallRetrofitAPI);
startActivity(intent);
并在MainActivity(成功登录后要调用的第二个活动)
Intent intent = getIntent();
LoginModelUsedToCallRetrofitAPI loginModelUsedToCallRetrofitAPI = intent.getSerializableExtra("DESIRE_KEY");
这应该做你想要的!