I have a knox activation key and I try to activate the license with the following code.
//EnterpriseLicenseManager is part of the samsung-knox api
EnterpriseLicenseManager.getInstance(context).activateLicense("<knox key here>");
This call will start an Activity to display the license text to the user with a "Confirm" and a "Cancel" button.
To get results of this license activation process I have a receiver (as recommended in the docs) :
<receiver android:name="com.company.LicenseReceiver">
<intent-filter>
<action android:name="edm.intent.action.license.status" />
</intent-filter>
</receiver>
And the code :
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if ( extras != null ) {
String status = extras.getString(EnterpriseLicenseManager.EXTRA_LICENSE_STATUS);
int errorCode = extras.getInt(EnterpriseLicenseManager.EXTRA_LICENSE_ERROR_CODE);
Toast.makeText(context, "License status :"+status+" - error:"+errorCode, Toast.LENGTH_LONG).show();
}
intent.getExtras();
}
I did some tests :
accept the license. (I did this multiple times)
Results : as expected a Toast with
License status :success - error:0refuse the license
Results : as expected a Toast with
License status :fail - error:601(The knox doc indicate that error 601 means that "user refused the license")
So far so good, now I did a third test :
accept the license.
Results : a Toast with
License status :success - error:0and immediately after that : another Toast withLicense status :fail - error:601
It means that I receive 2 broadcasts : the first one indicating a success as expected and another one : obviously coming back from my test n°2.
I tried to reboot the device and then accept the license : same results (i.e. I receive 2 broadcasts)
Any one have an idea on how to get rid of this phantom broadcast ?
0 comments:
Post a Comment