converting BACK to HOME

marcick

Well-Known Member
Licensed User
Longtime User
I would like when the user press the BACK button, the App behave like if he pressed HOME.
I know how intercept the BACK button, but I can't simulate the HOME.
This is my failed attempt:
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 
        
    If KeyCode= KeyCodes.KEYCODE_BACK Then
        Dim KC As Int
        KC = KeyCodes.KEYCODE_HOME
         Activity_KeyPress (KC) 
      Return True
   End If

End Sub

Any hints ?
Marco
 

ivanomonti

Expert
Licensed User
Longtime User
Here is the missing piece:
B4X:
Sub ShowHomeScreen
   Dim i As Intent
   i.Initialize(i.ACTION_MAIN, "")
   i.AddCategory("android.intent.category.HOME")
   i.Flags = 268435456
   StartActivity(i)
End Sub

Hi Erel;

I need to disable and re-enable the home button, but not using the mode according kios

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean

  If KeyCode = KeyCodes.KEYCODE_BACK and disableback = true Then
  Select Msgbox2 ("Keypad lock back", "", "", "", "Close", Null)
  Case DialogResponse.NEGATIVE
  Return True
  Case DialogResponse.CANCEL
   Return True
  Case DialogResponse.POSITIVE
  Return True
  end Select
  end If

If KeyCode = KeyCodes.KEYCODE_HOME and disablehome = true Then
  Select Msgbox2 ("Keypad lock home", "", "", "", "Close", Null)
  Case DialogResponse.NEGATIVE
  Return True
  Case DialogResponse.CANCEL
   Return True
  Case DialogResponse.POSITIVE
  Return True
  end Select
  end If

  end Sub

Thank
 
Upvote 0
Top