I want to disable the back button for my android app. All I want to do is, when the user presses the back button, nothing should happen. Basically like return false in JavaScript. The following is the code that I have in my MainActivity that I am using currently:
package com.ws.gostock;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(Config.getStartUrl());
}
@Override
public void onBackPressed()
{
System.out.println("back pressed");
}
}
Tried to run in debug mode, What happens is, when I press the back button the app closes, and then the code starts to debug. I don't know why.