Syntax error on 'onBackPressed()' 
<p>I am displaying a dialog box. When the back key pressed, I am writing a code and using back key default functionality, but every time I get following error, here is my code: </p>

<pre><code>public void myfunc {
        new AlertDialog.Builder(TaxiPlexer.this).setIcon(android.R.drawable.ic_dialog_alert).setTitle("Enable GPS").setMessage(
                "Please Enable GPS in device settings to use Taxi application").setPositiveButton("OK", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                 //do something
            } // onClick                

        }).show();

        @Override //error: Syntax error on token(s), misplaced construct(s)
        public void onBackPressed() {   //error: Syntax error on token "void", @ expected       
            GPSdialog = false;
            super.onBackPressed();
        } }
</code></pre>
