0

Possible Duplicate:
Activity has leaked window that was originally added

My browser crashes when I try to download an APK file. I have tried to do this in two different ways:

  1. Calling:

    Intent intent = new Intent(Intent.ACTION_VIEW,
      Uri.parse("http://myUrl/myFile.apk"));
    startActivity(intent);
    
  2. Letting the user click on a link in an alertDialog like:

    String myUrl = "http://myUrl/myFile.apk";
    final AlertDialog d = new AlertDialog.Builder(context) 
      .setPositiveButton("Dismiss", listener)
      .setCancelable(false)
      .setIcon(iconId)
      .setTitle(title)
      .setMessage(Html.fromHtml("<a href=\"" + myUrl + "\">MyLink</a>")) 
      .create();
    d.show();
    

Either way, the browser starts and shows a dialog, something about saving to an SD card, and then the dialog disappears and nothing more happens. I don't have an SD card (if I instead mount an SD card, I don't have a problem) but I need this to work without crashing if the user does not have an SD card.

In Logcat I can see:

Activity com.android.browser.BrowserActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@2bff4f40 that was originally added here

What can I do about this?

Community
  • 1
  • 1
user1140596
  • 121
  • 1
  • 1
  • 10
  • Possible duplicate of [this](http://stackoverflow.com/q/2850573/1101070). – Marvin Pinto Mar 01 '12 at 15:45
  • I am very sorry that this was closed down since I don´t think it is a duplicate. The other question, that was pointed out, was about dismissing your own alerts and I know how that works. But maybe I should have been more clear in my question. I wanted to know why the browser has this problem, that it can´t download a file if the SD card is missing. As I completely leave the download work to the standard browser I surely can´t do anything about dismissing the browsers own alerts. So the question was not about browser memory leaks, it was about browser download problems!! – user1140596 Mar 06 '12 at 08:26

1 Answers1

2

Call Environment.getExternalStorageState() to test if the SD-Card is mounted. And if not thant don't start the download.

Thommy
  • 5,070
  • 2
  • 28
  • 51