LVL(Android用ライセンス検証ライブラリ)を実装しようとしていますが、ライセンスチェックが失敗すると問題が発生します。ライセンスチェックが失敗したことを説明するダイアログをポップアップし、2つのボタンを表示します。1つのボタンは、すぐに別のチェックを実行したい「再試行」または「アプリの購入」で、アプリマーケットでアプリを購入するようにリダイレクトします。
[再試行]ボタンをタップすると、ログメッセージから、ライセンスチェックが呼び出され、別の「許可しない」コールバックを受け取り、上記の失敗ダイアログを再度表示しようとします(onPrepareDialog()が再度呼び出されるのがわかります)。
問題は、2番目のダイアログが実際に表示されないことです。そのため、ライセンスチェックに失敗した場合でも、ユーザーはアプリを使用できます。ダイアログが何度もポップアップしないのはなぜですか?
これが関連するすべてのコードだと思います。
private void checkLicense() {
Log.d(TAG, "Checking License...");
this.licenseChecker.checkAccess(this.licenseCheckerCallback);
}
private class MyLicenseCheckerCallback implements LicenseCheckerCallback {
public void allow() { }
public void dontAllow() {
Log.d(TAG, "License resposne: Don't Allow");
if (isFinishing())
return; // Don't update UI if Activity is finishing.
// 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 Market.
Log.d(TAG, "Showing No License Dialog");
showDialog(DIALOG_NO_LICENSE_ID);
}
public void applicationError(ApplicationErrorCode errorCode) {
if (isFinishing())
return; // Don't update UI if Activity is finishing.
// This is a polite way of saying the developer made a mistake
// while setting up or calling the license checker library.
showDialog(DIALOG_APPLICATION_ERROR_ID);
}
}
protected Dialog onCreateDialog(int id) {
Log.d(TAG, "Creating Dialog "+id);
switch(id) {
case DIALOG_NO_LICENSE_ID:
return this.makeRetryPurchaseDialog(getString(R.string.no_license));
case DIALOG_APPLICATION_ERROR_ID:
return this.makeRetryPurchaseDialog(this.applicationErrorMessageForDialog);
}
return null;
}
private Dialog makeRetryPurchaseDialog(String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(CalculatorTabActivity.this);
builder.setMessage(message).setCancelable(false)
.setPositiveButton("Retry", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
CalculatorTabActivity.this.checkLicense();
}
}).setNegativeButton("Purchase App", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
CalculatorTabActivity.this.openAppMarket();
}
});
return builder.create();
}