You can override `onBackPressed()` in your `Activity` or if you're talking about the dialog, just don't make it cancelable.
– Gergely KőrössyMar 08 '17 at 02:23
But is there anyway I could disable in Application Class subclass but activity
– markMar 08 '17 at 03:56
I don't understand your question. The `Application` context represents *no possible UI interaction*, hence there's no such thing as suppressing back presses. What is your use case? What are you trying to achieve? I have a feeling that you don't understand the basic concepts of Android, such as `Activity` and `Application`.
– Gergely KőrössyMar 08 '17 at 04:29
I have a Class say ClassA that extend Application
when ClassA.oncreate called, it will check if new app version is availble and if it does, it will prompt a dialog with an button, and this is what i have implemented
– markMar 08 '17 at 04:49
when user click that button, it will start an activity that do update on background and show update progress on UI
and I have also implemented that activity
– markMar 08 '17 at 04:50
but the thing is i want to prevent user from pressing back button right after dialog prompt in my Class A that extend Application Class
and since that is not an activity I couldn't override onBackPressed, and i was wondering if there anyway or workaround I could acheive the same purpose
– markMar 08 '17 at 04:53
You should not display a dialog from a non-`Activity` class, I guess you hack with the dialog type by making it system dialog. If you do what I think, there's no solution for that, you cannot block the user from pressing back button. Is this what you're doing? If not, please include some code in your question.
– Gergely KőrössyMar 08 '17 at 05:40
@mark Maybe you could use an Activity that isn't full screen to act as the dialog. (I forget which theme you need.) Then you can override `onBackPressed()` in the activity to handle/ignore the back button press.
– ban-geoengineeringMar 08 '17 at 11:22