Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6662899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:26:25+00:00 2026-05-26T02:26:25+00:00

I created one alert dialog box, it’s working fine for me. Now i am

  • 0

I created one alert dialog box, it’s working fine for me. Now i am expect to create if i press f2 button in softkeyboard i wish to show alertbox that’s all. I tried but its not working. Sample code please.

my coding:

public class HelloList extends Activity  
{

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle State) {
        super.onCreate(State);


         setContentView(R.layout.main);
         AlertDialog.Builder alertbox = new AlertDialog.Builder(this);

         // set the message to display
         alertbox.setMessage("Disclaimer popup window sample..hai.kjidj kjdij idfjdfojodifjdojfodjfodijfoidjfoidjf kdfjdifudjf difjdfjodfjdjfodf jd fojjidjfdfjdofjdfojfodjfodjfodjfojdfojdfojdofjodjfodjfl  dfjdofjdofj dfdjfodjf difjdoifj dfijdf ");

         // set a positive/yes button and create a listener
         alertbox.setPositiveButton("Agree/Close", new DialogInterface.OnClickListener() {

             // do something when the button is clicked
             public void onClick(DialogInterface dialog, int arg1) {
                 dialog.cancel();

             }
         });

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

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

             // display box
         alertbox.show();
        }
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_MENU)) {
        //Dialog dialog = null;
            moveTaskToBack(true);
        //return true;
        //    dialog.dismiss();
        }
        return super.onKeyDown(keyCode, event);


    }    
}

if i click f2 i wist to show dialog box…

10-04 18:57:28.936: DEBUG/dalvikvm(126): GC_EXPLICIT freed 1904 objects / 110176 bytes in 131ms
10-04 18:57:33.925: DEBUG/dalvikvm(174): GC_EXPLICIT freed 207 objects / 14032 bytes in 113ms
10-04 18:57:38.915: DEBUG/dalvikvm(266): GC_EXPLICIT freed 130 objects / 6264 bytes in 98ms
10-04 18:57:52.866: WARN/KeyCharacterMap(663): No keyboard for id 0
10-04 18:57:52.866: WARN/KeyCharacterMap(663): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
10-04 18:57:52.886: DEBUG/AndroidRuntime(663): Shutting down VM
10-04 18:57:52.886: WARN/dalvikvm(663): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-04 18:57:52.906: ERROR/AndroidRuntime(663): FATAL EXCEPTION: main
10-04 18:57:52.906: ERROR/AndroidRuntime(663): java.lang.NullPointerException
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at videothumb.videothumb.videothumb.onKeyDown(videothumb.java:138)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at android.view.KeyEvent.dispatch(KeyEvent.java:1037)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at android.app.Activity.dispatchKeyEvent(Activity.java:2068)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1643)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2471)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2441)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1735)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at android.os.Looper.loop(Looper.java:123)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at android.app.ActivityThread.main(ActivityThread.java:4627)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at java.lang.reflect.Method.invokeNative(Native Method)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at java.lang.reflect.Method.invoke(Method.java:521)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-04 18:57:52.906: ERROR/AndroidRuntime(663):     at dalvik.system.NativeStart.main(Native Method)
10-04 18:57:52.926: WARN/ActivityManager(59):   Force finishing activity videothumb.videothumb/.videothumb
10-04 18:57:53.465: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{44f41b20 videothumb.videothumb/.videothumb}
10-04 18:57:59.436: DEBUG/dalvikvm(196): GC_EXPLICIT freed 72 objects / 2936 bytes in 99ms
10-04 18:58:04.222: WARN/ActivityManager(59): Activity destroy timeout for HistoryRecord{44f41b20 videothumb.videothumb/.videothumb}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:26:25+00:00Added an answer on May 26, 2026 at 2:26 am

    show alertdialog box in if block of onKeyDown method and return true in place of return super.onKeyDown(keyCode, event);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i created one grid view application, it's working fine now showing all images in
I created one application, its working fine. I want to support my application in
I need to create alert dialog with 3 check boxes....And when top check box
I have one button when I click the button it shows the alert dialog
I created one GWT webapplication project.Inthat i want to create servlet program,but in that
I have created one listview, in this each row contain check box and the
I have created one table using the below command: create table Table1( Id int
I have a button in android which on clicking produces an alert box. But
I am trying to create an Alert Dialog with a list of single-choice items
When I run this code the alert dialog is shown but there is one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.