I'm implementing the licensing in my App but I didn't found an official list of response codes.
The piece of script that return the code (int policyReason
) is this:
private class MyLicenseCheckerCallback implements LicenseCheckerCallback {
public void allow(int policyReason) {
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
// Should allow user access.
displayResult(getString(R.string.allow));
}
public void dontAllow(int policyReason) {
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
displayResult(getString(R.string.dont_allow));
// Should not allow access. In most cases, the app should assume
// the user has access unless it encounters this. If it does,
// the app should inform the user of their unlicensed ways
// and then either shut down the app or limit the user to a
// restricted set of features.
// In this example, we show a dialog that takes the user to a deep
// link returned by the license checker.
// If the reason for the lack of license is that the service is
// unavailable or there is another problem, we display a
// retry button on the dialog and a different message.
displayDialog(policyReason == Policy.RETRY);
}
public void applicationError(int errorCode) {
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
// This is a polite way of saying the developer made a mistake
// while setting up or calling the license checker library.
// Please examine the error code and fix the error.
String result = String.format(getString(R.string.application_error), errorCode);
displayResult(result);
}
}
I found these here (unofficial, the link provided points to an official documentation without int codes):
Response Code Value Licensed 256 Not_licensed 561 Error_Server_Failure 291 Error_Contacting_Server 291 Error_Not_Market_Managed 3 Error_Invalid_Package_Name 1 Error_Non_Matching_UID 2
and these here (unofficial, without link to a official documentation with int codes):
LICENSED = Hex: 0x0100, Decimal: 256 NOT_LICENSED = Hex: 0x0231, Decimal: 561 RETRY = Hex: 0x0123, Decimal: 291 LICENSED_OLD_KEY = Hex: 0x2, Decimal: 2 ERROR_NOT_MARKET_MANAGED = Hex: 0x3, Decimal: 3 ERROR_SERVER_FAILURE = Hex: 0x4, Decimal: 4 ERROR_OVER_QUOTA = Hex: 0x5, Decimal: 5 ERROR_CONTACTING_SERVER = Hex: 0x101, Decimal: 257 ERROR_INVALID_PACKAGE_NAME = Hex: 0x102, Decimal: 258 ERROR_NON_MATCHING_UID = Hex: 0x103, Decimal: 259
But in the official documentation for the LicenseValidator
class there are these:
// Server response codes.
private static final int LICENSED = 0x0;
private static final int NOT_LICENSED = 0x1;
private static final int LICENSED_OLD_KEY = 0x2;
private static final int ERROR_NOT_MARKET_MANAGED = 0x3;
private static final int ERROR_SERVER_FAILURE = 0x4;
private static final int ERROR_OVER_QUOTA = 0x5;
private static final int ERROR_CONTACTING_SERVER = 0x101;
private static final int ERROR_INVALID_PACKAGE_NAME = 0x102;
private static final int ERROR_NON_MATCHING_UID = 0x103;
(edit) For example, policyReason
may returns 291
and 256
but these aren't in LicenseValidator
(0x101
= 257
, 0x102 =
258,
0x103=
259`).
Where I can find an official documentation that contains the list of int's response codes to rely on?
I already searched in the lvl-library
module but without success.
(edit2) Thanks to @Mir Milad Hosseiny's answer now I know precisely where to find these int codes. But now I have a doubt: why does allow should return RETRY or NOT_LICENSED and dontAllow RETRY and LICENSED? Because of their names they shoudn't return nothing than respectively LICENSED and NOT_LICENSED/RETRY. I must know how to properly handle the case when the user did download my App from Google Play. I asked a dedicated question about that here.
Thanks a lot!