@@ -87,20 +87,19 @@ protected LicenseCheckingMessage doInBackground(Void... params) {
87
87
private LicenseCheckingMessage checkLicense (int nonce ) {
88
88
Intent intent = new Intent ("com.android.vending.licensing.ILicensingService" );
89
89
intent .setPackage ("com.android.vending" );
90
- boolean bindResult = activity .bindService (intent ,
91
- new ServiceConnection () {
92
- @ Override
93
- public void onServiceConnected (ComponentName name , IBinder s ) {
94
- service = ILicensingService .Stub .asInterface (s );
95
- }
96
-
97
- @ Override
98
- public void onServiceDisconnected (ComponentName name ) {
99
- Log .w (TAG , "Service unexpectedly disconnected." );
100
- service = null ;
101
- }
102
- },
103
- Context .BIND_AUTO_CREATE );
90
+ ServiceConnection serviceConnection = new ServiceConnection () {
91
+ @ Override
92
+ public void onServiceConnected (ComponentName name , IBinder s ) {
93
+ service = ILicensingService .Stub .asInterface (s );
94
+ }
95
+
96
+ @ Override
97
+ public void onServiceDisconnected (ComponentName name ) {
98
+ Log .w (TAG , "Service unexpectedly disconnected." );
99
+ service = null ;
100
+ }
101
+ };
102
+ boolean bindResult = activity .bindService (intent , serviceConnection , Context .BIND_AUTO_CREATE );
104
103
105
104
if (!bindResult ) {
106
105
Log .e (TAG , "Could not bind to service." );
@@ -155,6 +154,8 @@ public void verifyLicense(int responseCode, String signedData, String signature)
155
154
return new LicenseCheckingMessage ("Could not check license from licensing service in time" );
156
155
}
157
156
157
+ activity .unbindService (serviceConnection );
158
+
158
159
/* Response codes:
159
160
private static final int LICENSED = 0x0;
160
161
private static final int NOT_LICENSED = 0x1;
0 commit comments