Reputation: 23
Users of my Android TV (Nexus Player, NVIDIA Shield TV, Razer Forge TV, etc.) app sometimes do not have a Google account linked to their device. I want my app to send them to the Android TV "Add Account" activity.
Here is the code that I have tried:
Intent intent = new Intent();
intent.setAction(Settings.ACTION_ADD_ACCOUNT);
intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, new String[]{"com.google"});
startActivity(intent);
This code does not work, although in the logcat I see the following:
I/ActivityManager: START u0 {act=android.settings.ADD_ACCOUNT_SETTINGS cmp=com.android.tv.settings/.accounts.AccountSettingsActivity (has extras)} from uid 10089 on display 0
Why does this do nothing?
Upvotes: 1
Views: 185
Reputation: 23
This works:
Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"}, false, null, null, null, null);
startActivityForResult(intent, 1);
Upvotes: 1