I have a BroadcastReceiver
which calls a IntentService
. I am getting the following error when the receiver code is finished running.
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'
Here is my code:
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();
}
}
}