Hi all,
How i can exit from an application?

Button exit     =   (Button)findViewById(R.id.exit_btn);
            exit.setOnClickListener(new Button.OnClickListener() {

                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    finish();
                    java.lang.System.exit(0);

                }

            });

this code just takes me to the last activity but i want to completely close the application

That is what happen if you each time just start new activity and do not close the old one. If you search stackoverflow forum you will find plenty posts about this.
The best way is to leave out specific "Exit" button and let user to hit home key, or if you must then call on home key press on the press of the button

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.