Android 5.0 (L) Service Intent must be explicit in Google analytics

后端 未结 11 1675
南旧
南旧 2020-11-29 02:01

My code worked in <5 but in Android 5.0 I\'m running into an issue that I don\'t quite understand.

10-23 10:18:18.945: E/AndroidRuntime(8987): java.lang.I         


        
11条回答
  •  孤街浪徒
    2020-11-29 02:32

    I'm working on a project where we want to allow users to use older devices. I came up with the same solution as the one mentioned in Marias answer, however I've added a conditional statement for the setPackage call since it is only available in API 4 (Ice Cream Sandwich == SDK 14) and above. If developing for versions below that I reckon you don't need to include the setPackage call.

    In function com.google.android.vending.licensing.LicenseChecker.checkAccess(callback)

    Intent serviceIntent = new Intent(new String(
    Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")));
    
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        serviceIntent.setPackage("com.android.vending");
    }
    
    boolean bindResult =
        mContext.bindService(
            serviceIntent,
            this, // ServiceConnection.
            Context.BIND_AUTO_CREATE);
    

提交回复
热议问题