I have tried the approach below to automatically login current User. But onDestroy, User still has to login
public class LoginActivity extends AppCompatActivity {
private Client client;
private Account account;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
client = new Client();
client.setEndpoint("https://[HOSTNAME_OR_IP]/v1");
client.setProject("[PROJECT_ID]");
client.setKey("[API_KEY]");
account = new Account(client);
}
@Override
protected void onResume() {
super.onResume();
try {
account.get(new CoroutineCallback<>(
(result, error) -> {
if (error != null)
error.printStackTrace();
return;
}
));
// User is logged in
} catch (AppwriteException e) {
// User is not logged in
}
}
}
What exactly happens when this is executed? It doesn't look like you're doing anything with the result of account.get() sooooo š§
@Override
protected void onResume() {
super.onResume();
AppwriteClient appwriteClient = new AppwriteClient(getApplicationContext());
Account account = appwriteClient.getAccount();
try {
account.get(new CoroutineCallback<>(
(result, error) -> {
if (result != null)
startActivity(new Intent(LoginActivity.this, MainActivity.class));
Log.d("appwrite", "onResume:result " + result);
}
));
} catch (AppwriteException e) {
e.printStackTrace();
finish();
}
}
@Steven sorry for late reply. I have added a navigation so mainFragment. But i still get the same result. It lunches the loginActivity before navigating
So the onResume is being logged?
Yes, When they is an active Session, But the problem is when onResume loginActivity appears for atleast 1.5 sec before navigating to Mainfragment
sorry i don't understand. also, what is the result that's logged?
The log shows the user in active session. But my concern is the delay before resuming active session
What do you mean?
Recommended threads
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...
- I'm experiencing a critical bug on Appwr...
Hey <@870607367597850624> team / support š I'm experiencing a critical bug on Appwrite Cloud that's blocking my production Flutter app. I've already filed GitH...
- Database listRows method call failing in...
I'm getting an error when trying to use listRows in a flutter app on a database. It seems something in the backend has changed because the production version of...