From my activity A open a device setting page with firing the intent.can i listen back key press event on the device settings page.
e.gSettings.ACTION_APN_SETTINGS
From my activity A open a device setting page with firing the intent.can i listen back key press event on the device settings page.
e.gSettings.ACTION_APN_SETTINGS
Assuming your settings page is an Activity
, you can override the onBackPressed()
method:
@Override
public void onBackPressed() {
// Do stuff.
}
or
@Override
protected boolean onKeyDown(int keyCode, KeyEvent event) {
// Do stuff if event == KeyEvent.KEYCODE_BACK.
}
Edit.
If you're thinking of listening (and processing) back presses in Activity A while your settings page is displayed, consider using a Fragment for your settings page, which you add and display in Activity A.
Edit 2 - answer to your comment:
As far as I know, there is no way to listen for e.g. wifi on/off clicks, but what you can do is the following:
startActivityForResult(new Intent(Settings.ACTION_WIFI_SETTINGS), 0xB00B);
then
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK && requestCode == 0xB00B) {
// Check if WIFI is on/off. That way you know what the user pressed.
}
}