perjantai 30. joulukuuta 2011

Leadbolt Appwall example

In this example im going to create a dialogbox that appears when user presses the back-button.
The buttons in the dialog box will be Quit, Cancel and Top Apps. Top Apps will launch Leadbolt Appwall and the others are self explanatory.

Simply Change the Leadbolt url to your Appwall url. I use this on the main menu screen of my apps.

If you are not using Leadbolt at the moment i would suggest that you give it a try. I get 4 times better income than from  Admob or Mobclix. Register as an Leadbolt publisher HERE



Here's the code:

     @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)  {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
          //  builder.setTitle("Test");  IF YOU WANT TO SET SEPARATE TITLE
          //  builder.setIcon(R.drawable.ic_launcher); // ICON FOR YOUR ALERTDIALOG
            builder.setCancelable(false); // disable back-button
            builder
                    .setMessage("Do you want to Quit?");
            builder.setPositiveButton("Top Apps",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                        String url = "http://ad.leadboltads.net/show_app_wall?section_id=XXXXX"; //YOUR LEADBOLT APPWALL ADRESS HERE!!
                        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                            startActivity(intent);
                        }
                    });
            builder.setNeutralButton("Quit", //Quit-button
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                        finish();
                        }
                    });
            builder.setNegativeButton("Cancel", //Cancel-button
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
            builder.show();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }


5 kommenttia: