Une ressource a été acquis à joint trace de la pile, mais ne sont jamais sortis de l'Erreur
Je ne sais pas pourquoi j'obtiens cette erreur, 2 fois sur 5 j'ai mis le fond d'écran en utilisant l'émulateur, j'obtiens l'erreur
"Une ressource a été acquis à joint trace de la pile, mais jamais publiée. Voir java.io.Fermer pour plus d'informations sur la façon d'éviter les fuites de ressource."
Quand j'ai mis le papier peint à l'aide de mon téléphone, il fonctionne parfaitement sans faute. Pourquoi ça plante quand je l'utilise j'utilise l'émulateur?
Voici mon code:
public class SetWallpaperAsync extends AsyncTask<String, String, String> {
private Context context;
private ProgressDialog pDialog;
String image_url;
URL mImageUrl;
String myFileUrl1;
Bitmap bmImg = null;
public SetWallpaperAsync(Context context) {
this.context = context;
}
@Override
protected void onPreExecute() {
//TODO Auto-generated method stub
super.onPreExecute();
pDialog = new ProgressDialog(context);
pDialog.setMessage("Setting Wallpaper...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected String doInBackground(String... args) {
//TODO Auto-generated method stub
try {
mImageUrl = new URL(args[0]);
//myFileUrl1 = args[0];
HttpURLConnection conn = (HttpURLConnection) mImageUrl
.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Config.RGB_565;
Bitmap bmImag = BitmapFactory.decodeStream(is, null, options);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String args) {
//TODO Auto-generated method stub
WallpaperManager wpm = WallpaperManager.getInstance(context);
try {
wpm.setBitmap(bmImg);
} catch (IOException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
pDialog.dismiss();
}
}
JOURNAL de Chat:
11-09 15:09:11.726: E/StrictMode(1632): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
11-09 15:09:11.726: E/StrictMode(1632): java.lang.Throwable: Explicit termination method 'end' not called
11-09 15:09:11.726: E/StrictMode(1632): at dalvik.system.CloseGuard.open(CloseGuard.java:184)
11-09 15:09:11.726: E/StrictMode(1632): at java.util.zip.Inflater.<init>(Inflater.java:82)
11-09 15:09:11.726: E/StrictMode(1632): at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:96)
11-09 15:09:11.726: E/StrictMode(1632): at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:81)
11-09 15:09:11.726: E/StrictMode(1632): at libcore.net.http.HttpEngine.initContentStream(HttpEngine.java:528)
11-09 15:09:11.726: E/StrictMode(1632): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:836)
11-09 15:09:11.726: E/StrictMode(1632): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
11-09 15:09:11.726: E/StrictMode(1632): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486)
11-09 15:09:11.726: E/StrictMode(1632): at com.google.ads.internal.f.b(SourceFile:490)
11-09 15:09:11.726: E/StrictMode(1632): at com.google.ads.internal.f.run(SourceFile:460)
11-09 15:09:11.726: E/StrictMode(1632): at java.lang.Thread.run(Thread.java:856)
OriginalL'auteur Jack | 2013-11-09
Vous devez vous connecter pour publier un commentaire.
Émulateurs ont StrictMode par défaut, sur les appareils, il peut être activé dans le code via:
L'accident que vous obtenez ici est dit que vous devez fermer manuellement ouvert les ressources du web afin de pouvoir libérer de la mémoire, voir cet exemple de Android docs:
OriginalL'auteur marmor