'Trusted Web Activity [TWA] - Can it read AccountManager accounts on Android?

Problem: Attempting to read accounts created via AccountManager API in Android via a TWA LauncerActivity.

  • I'm aware that some native functionality isn't possible in Android, and if I am attempting something that is impossible please link me a resource. I haven't came across anything explicitly about account manager access.

I have confirmed I have accounts on device, and am attempting a print out to Logcat of all of the accounts, but I am returned no results:

    private void printAccounts() {
        Account[] accounts = AccountManager.get(this).getAccounts();

        Log.d("FoundAccount", "Total accounts: " + accounts.length);

        for (Account account : accounts) {
            Log.d("FoundAccount", ": " + account.name);
        }
    }

Resulting output via Logcat:
D/FoundAccount: Total accounts: 0

Any resources would be greatly appreciated, thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source