Example usage for android.app Activity onKeyDown

List of usage examples for android.app Activity onKeyDown

Introduction

In this page you can find the example usage for android.app Activity onKeyDown.

Prototype

public boolean onKeyDown(int keyCode, KeyEvent event) 

Source Link

Document

Called when a key was pressed down and not handled by any of the views inside of the activity.

Usage

From source file:Main.java

public static ProgressDialog createProgressDialog(final Activity activity, int progressDialogTitleId,
        int progressDialogMsgId) {
    ProgressDialog progressDialog = new ProgressDialog(activity);
    if (progressDialogTitleId > 0) {
        progressDialog.setTitle(progressDialogTitleId);
    } else {/*  w  w w  .j  a v a2  s  .  c  om*/
        progressDialog.setTitle(activity.getResources().getIdentifier(PROGRESS_DIALOG_TITLE_RESOURCE, "string",
                activity.getPackageName()));
    }
    if (progressDialogMsgId > 0) {
        progressDialog.setMessage(activity.getString(progressDialogMsgId));
    } else {
        progressDialogMsgId = activity.getResources().getIdentifier(PROGRESS_DIALOG_MESSAGE_RESOURCE, "string",
                activity.getPackageName());
        progressDialog.setMessage(activity.getString(progressDialogMsgId));
    }
    progressDialog.setIndeterminate(true);
    progressDialog.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            activity.onKeyDown(keyCode, event);
            return false;
        }
    });
    // progressDialog.setInverseBackgroundForced(true);
    return progressDialog;
}