J'ai une application gratuite qui contient également des fonctionnalités pro, qui seront disponibles à l'utilisateur s'ils achètent une clé pro pour mon application dans l'Android Market. J'ai mis en place un récepteur dans l'application clé Pro et un autre dans l'application principale. Lorsque l'utilisateur clique sur un bouton "Valider la clé" dans l'application principale, une intention est diffusée au récepteur dans l'application clé, qui déclenche ensuite un IntentService pour vérifier si la licence Pro Key est valide. Ensuite, IntentService diffuse une intention sur le récepteur de l'application principale contenant une "réponse" supplémentaire de la vérification LVL.LVL contrôle de licence de Intent Service
Je suis presque arrivé. Seulement quand j'ai essayé de faire le contrôle de LVL dans le IntentService, je suis une erreur:
W/MessageQueue(2652): java.lang.RuntimeException: Handler{4052de20} sending message to a Handler on a dead thread
W/MessageQueue(2773): at com.android.vending.licensing.LicenseChecker$ResultListener.verifyLicense(LicenseChecker.java:207)
Toutes les suggestions?
la source IntentService:
public class CheckerService extends IntentService {
private static final byte[] SALT = ....;
private static final String BASE64_PUBLIC_KEY = ...;
private String device_id;
public CheckerService() {
super("CheckerService");
}
@Override
protected void onHandleIntent(Intent intent) {
SharedPreferences data = getSharedPreferences("data", MODE_PRIVATE);
device_id = data.getString("device_id", null);
if (device_id == null) {
SharedPreferences.Editor editor = data.edit();
device_id = new DeviceId().generate(this);
editor.putString("device_id", device_id);
editor.commit();
}
ServerManagedPolicy smp = new ServerManagedPolicy(this,
new AESObfuscator(SALT, getPackageName(), device_id));
LicenseChecker checker = new LicenseChecker(this, smp, BASE64_PUBLIC_KEY);
checker.checkAccess(new LicenseCheckerCallback(){
public void allow() {
Intent i = new Intent();
i.setAction("com.mainapp.intent.action.LICENSE_RESPONSE");
i.putExtra("response", "LICENSE_OK");
sendBroadcast(i);
}
public void dontAllow() {
Intent i = new Intent();
i.setAction("com.mainapp.intent.action.LICENSE_RESPONSE");
i.putExtra("response", "LICENSE_NOT_OK");
sendBroadcast(i);
}
public void applicationError(ApplicationErrorCode errorCode) {
Intent i = new Intent();
i.setAction("com.mainapp.intent.action.LICENSE_RESPONSE");
i.putExtra("response", "LICENSE_ERROR");
sendBroadcast(i);
}});
}
@Override
public void onDestroy() {
super.onDestroy();
checker.onDestroy();
}
}
Avez-vous pu le faire? Il doit y avoir plus d'exemples LVL –