Reputation: 1751
After user logged in successfully, there will be another api call to get the user information. But before the response I will close the activity and start the home activity.
public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
//save token
// call REST service to get user info and update the user records on DB.
// update the notification token info
//go to home page
Intent intent = new Intent(SigninActivity.this, HomeActivity.class);
startActivity(intent);
finish();
}
How can I make the call REST calls outside the activity. So App can handle the onReponse even after I close the Activity.
In General How can we call the API to do the background activity (eg: update database.) without any interaction . (response doesn't depend on activity)
Upvotes: 1
Views: 1518
Reputation: 10661
There are two ways of doing this
Upvotes: 0
Reputation: 473
You could run a service(async) in the background minimize the first app and onResponse kill the first app and start the 2nd. And just access the data from the first.
Upvotes: 0
Reputation: 16429
The easiest solution would be to use static method. You can call those methods from anywhere.
If you want to update UI elements inside that method, pass the UI elements as parameters to the static method.
Upvotes: 1