0

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();
        }
    }
}
Boomerang
  • 167
  • 1
  • 6
  • Maybe: http://stackoverflow.com/questions/25544021/a-resource-was-acquired-at-attached-stack-trace-but-never-released-see-java-io –  Sep 30 '15 at 05:03
  • The link is useful. How can i figure out, where is this error occurring ? – Boomerang Sep 30 '15 at 05:54
  • Try MAT from accepted answer. Posting `DownloadService` code might help us figuring out –  Sep 30 '15 at 07:18

0 Answers0