0

Can anyone figure out why this causes a force close??

void failbox(){
     // Create the alert box
       AlertDialog.Builder alertbox = new AlertDialog.Builder(this);

       // Set the message to display
       alertbox.setMessage(R.string.fail);

       alertbox.setPositiveButton("Get Busybox", new DialogInterface.OnClickListener() {

           // do something when the button is clicked
           public void onClick(DialogInterface arg0, int arg1) {


               Intent i = new Intent(Intent.ACTION_VIEW);  
               i.setData(Uri.parse("market://details?id=stericson.busybox"));
           }
           });

       // set a negative/no button and create a listener
       alertbox.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

           // do something when the button is clicked
           public void onClick(DialogInterface arg0, int arg1) {

           }
       });

        // show the alert box
       alertbox.show();

   }

Thanks in advance!

1 Answers1

0

If you're getting the forced close in the emulator, that's just how it is, as best I can tell. You cannot access the market through the market app from an emulator.

Does your app still crash when run on a real Android device?

(Of course, some folks have figured out sneaky ways to get to the market from an emulator. See How to install Android Market App on the emulator?)

Community
  • 1
  • 1
Thane Anthem
  • 4,093
  • 4
  • 26
  • 24