我正在尝试实施Android许可证。按指示做了一切。但是由于非许可证使用需要关闭应用程序。我得到了例外:
06-12 09:11:31.384: E/LicenseChecker(383): Could not bind to service.
06-12 09:11:36.884: E/ActivityThread(383): Activity com.myapp.main.mactivity has leaked ServiceConnection com.google.android.vending.licensing.LicenseChecker@406a4428 that was originally bound here
06-12 09:11:36.884: E/ActivityThread(383): android.app.ServiceConnectionLeaked: Activity com.myapp.main.mactivity has leaked ServiceConnection com.google.android.vending.licensing.LicenseChecker@406a4428 that was originally bound here
06-12 09:11:36.884: E/ActivityThread(383): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:932)
06-12 09:11:36.884: E/ActivityThread(383): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:827)
06-12 09:11:36.884: E/ActivityThread(383): at android.app.ContextImpl.bindService(ContextImpl.java:1082)
06-12 09:11:36.884: E/ActivityThread(383): at android.content.ContextWrapper.bindService(ContextWrapper.java:370)
06-12 09:11:36.884: E/ActivityThread(383): at com.google.android.vending.licensing.LicenseChecker.checkAccess(LicenseChecker.java:150)
是什么导致这个?
onCreate方法我创建:
mHandler = new Handler();
// Try to use more data here. ANDROID_ID is a single point of attack.
String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
// Library calls this when it's done.
mLicenseCheckerCallback = new MyLicenseCheckerCallback();
// Construct the LicenseChecker with a policy.
mChecker = new LicenseChecker(
this, new ServerManagedPolicy(this,
new AESObfuscator(SALT, getPackageName(), deviceId)),
BASE64_PUBLIC_KEY);
doCheck();
和onDestroy:
@Override
protected void onDestroy() {
super.onDestroy();
mChecker.onDestroy();
}
那么这个例外意味着什么呢?
答案 0 :(得分:2)
我也遇到了这个问题。我正在用4.0.4测试AVD Galaxy Nexus。
我尝试了其他线程的建议,使用getApplicationContext()而不是使用当前活动的上下文。但这没有帮助。
切换到真实设备确实解决了评论中提到的问题。
可能有效的另一个选项如下:
答案 1 :(得分:1)
如果您使用的是模拟器而不是设备:
基本问题是,当您尝试在模拟器上运行应用程序时,您没有登录到有效的测试帐户。