question

ismdcf avatar image
ismdcf asked Bryanne Vega commented

Clover Station 2018 Genymotion emulator CloverAccount.getAccount returning null

I'm using the "CloverAccount.getAccount()" method to get the clover account on an activity's onCreate() method as follows
private Account account;
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  account = CloverAccount.getAccount(this);
}
It works as expected on all the Genymotion emulators (clover mobile/mini/station)
except on the 2018 emulator that was configured using this link the getAccount() method always returns a null.

Another observation that I made was, when running the clover sdk sample app with the application id configured to my app which was uploaded to clover sandbox developer account, the getAccount() method returns the expected account and after which which running my app on top of the clover sdk sample app also returns the expected clover account (unless the app cache is cleared).
The difference between the clover sdk sample app and my application is that my app uses compileSdkVersion 26 while the clover sdk sample app uses compileSdkVersion 21 where the android.accounts.Account class are different from each other

I'm using 'com.clover.sdk:clover-android-sdk:183' to compile the clover sdk

Clover Android SDKClover StationEmulator
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

lilly avatar image
lilly Deactivated answered
Hi @ismdcf,

On https://docs.clover.com/build/android-emulator-set... you'll see that we noted for Station (2018) you should run API 21 or lower. Android introduced "grant at runtime" permissions, which on emulators requires you to go and manually approve all permissions the app is requesting.

For your situation, go into android Settings -> Apps -> your app -> Permissions and from there, you should enable all permissions.

Let us know if this does not work for you and we can investigate further.
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bryanne Vega avatar image
Bryanne Vega answered Bryanne Vega commented
Follow the sample code below:

//Check for permission, if not available, ask for it<br>String[] permissionsSet = new String[] {Manifest.permission.GET_ACCOUNTS};
<context>.requestPermissions(permissionsSet,YOUR_CODE_FOR_PERMISSION);
//Then see if the user approved your permission onActivityResult:
switch (requestCode){
	case YOUR_CODE_FOR_PERMISSION:
		if (resultCode == RESULT_OK){
			//continue your logic here
		}
}
  • It is of best practice to tell the users why you need the permission first before asking.
  • If the user declines the permission, retry explaining in more details why you need such permission
    • Don't stay in a loop until the user grants the permission.
Hope it helped!
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bryanne Vega avatar image Bryanne Vega commented ·

PS: Source, just tried it and it worked fine. I'm preparing my apps to comply with run-time while also exploring the 2018's screen size & adapting apps accordinly.

0 Likes 0 ·

Welcome to the
Clover Developer Community