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 8160429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:14:23+00:00 2026-06-06T18:14:23+00:00

I am using finish() to close current activity before quit application in Android. However,

  • 0

I am using finish() to close current activity before quit application in Android.

However, I cannot close screen in blackberry.

public class Main_AllLatestNews extends MainScreen {

public Main_AllLatestNews() {
    super(USE_ALL_WIDTH);
}

private boolean Dialog() {
    final Bitmap logo = Bitmap.getBitmapResource("icon.png");
    d = new Dialog("确定离开?", new String[] { "是", "否" }, new int[] {
            Dialog.OK, Dialog.CANCEL }, Dialog.OK,
            logo) {
        public void setChangeListener(FieldChangeListener listener) {
            if (d.getSelectedValue() == Dialog.OK) {

            } else {
                d.close();
            }
        };
    };
    d.show();
    return (d.doModal() == Dialog.OK);
}

public boolean onClose(){
    if(Dialog()){
        System.exit(0);
        return true;
    }else
        return false;
}
}

Here is my Main class

public class Main extends UiApplication {
public static void main(String[] args) {
    Main theApp = new Main();
    theApp.enterEventDispatcher();
}

public Main() {
    pushScreen(new MyScreen());
}

public final class MyScreen extends MainScreen {
    private Bitmap logo = Bitmap.getBitmapResource("logo_page.png");
    private BitmapField bmfield;

    public MyScreen() {
        setTitle("Oriental Daily");

        bmfield = new BitmapField(logo, Field.FIELD_HCENTER
                | BitmapField.FOCUSABLE) {
            protected boolean navigationClick(int status, int time) {
                Main.this.pushScreen(new Main_AllLatestNews());
                Main.this.popScreen(MyScreen.this);
                return true;
            }
        };
    }
}
  • 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-06-06T18:14:24+00:00Added an answer on June 6, 2026 at 6:14 pm

    It depends on exactly how you want your close behaviour to work. Also, I can only read English, so I’m not 100% sure what your Dialog says. I’m assuming it’s something to do with closing the app (yes or no)?

    Anyway, usually, my apps close by overriding the onClose() method in the MainScreen subclass. You don’t actually need to listen for the escape key. onClose() will get called normally when the user escapes all the way out of the app, or presses the little button with the blackberry icon, and then selects Close.

    public final class MyScreen extends MainScreen {
    
       /** @return true if the user chooses to close the app */
       private boolean showDialog() {       
          Bitmap logo = Bitmap.getBitmapResource("icon.png");
          Dialog d = new Dialog("确定离开?", 
                new String[] { "是", "否" }, 
                new int[] { Dialog.OK, Dialog.CANCEL }, 
                Dialog.OK,
                logo);       
          return (d.doModal() == Dialog.OK);
       }       
    
    
       /** Shutdown the app? */
       public boolean onClose() {
          if (showDialog()) {       
             System.exit(0);
             return true;
          } else {
             // the user does not want to exit yet
             return false;
          }
       }
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application is basically one Activity that I quit by calling this.finish(); System.exit(0); where
I always heard about to close any activity use finish or use android.os.Process.killProcess(android.os.Process.myPid()); first
Hi i want to know how to close an application in Android. Actually i
Everybody knows that you should close a connection immediately after you finish using it.
I'm writing a Excel class using Microsoft.Interropt.Excel DLL. I finish all function but I
I tried closing the application using the finish(), but finish() method just finishes the
i'm doing an application in asp.net using a class stack of my authorship to
In my android app i am launching an activity using Intent. this activity uses
I have an Android project with two activities. One is my main activity, using
I have a java class that creates a process, called child, using ProcessBuilder. The

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.