0

我有一个BroadcastReceiver叫 a 的IntentService。接收器代码完成运行时出现以下错误。

Error
 'A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
    java.lang.Throwable: Explicit termination method 'release' not called'

这是我的代码:

public class RestartReceiver extends BroadcastReceiver {

    private static final String TAG = "RestartReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        android.os.Debug.waitForDebugger();
        ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
        final NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        final NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
        if (wifi.isConnected() || mobile.isConnected()) {
            Intent downloadIntent=new Intent(context,DownloadService.class);
            context.startService(downloadIntent);
        }
        else {
            Toast.makeText(context, "No Network Connectivity", Toast.LENGTH_SHORT).show();
        }
    }
}
4

0 回答 0