У меня есть BroadcastReceiver
, который вызывает 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();
}
}
}
DownloadService
может помочь нам разобраться - person   schedule 30.09.2015