Google Play OBB下载器库在Android 8.0上崩溃

时间:2018-12-24 17:38:09

标签: android google-play android-8.0-oreo background-service

OBB下载器库似乎使用Context.startService(...)在后台下载OBB,但在Android 8.0上,如果应用程序本身在后台,则会导致崩溃。 该库注册了BroadcastReceiver:

mConnReceiver = new InnerBroadcastReceiver(this);
IntentFilter intentFilter = new IntentFilter(
        ConnectivityManager.CONNECTIVITY_ACTION);
intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
registerReceiver(mConnReceiver, intentFilter);

接收方istelf:

private class InnerBroadcastReceiver extends BroadcastReceiver {
    final Service mService;

    InnerBroadcastReceiver(Service service) {
        mService = service;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        pollNetworkState();
        if (mStateChanged
                && !isServiceRunning()) {
            Log.d(Constants.TAG, "InnerBroadcastReceiver Called");
            Intent fileIntent = new Intent(context, mService.getClass());
            fileIntent.putExtra(EXTRA_PENDING_INTENT, mPendingIntent);
            // send a new intent to the service
            context.startService(fileIntent);
        }
    }
};

崩溃堆栈状态: Downloader service crash

那么,避免此类崩溃的首选方法是什么?还是这种用户体验在Android 8.0+中是正常的?

0 个答案:

没有答案