Yuliy Polyakov
Yuliy Polyakov

Reputation: 97

Lock activity on the screen

I have a question about Android Activities.

How to lock current activity on screen and block any navigation/starting new activities?

I have a application, based on WebSocket communication system. And on new transaction started i need to wait for getting any communication result (success or error) and only then i can run new activity or go to previous activity.

But how to implement there? I need to universal method, who will be able to intercept any navigation attempts of standard keys and any navigation attempts of user code.

Thanks.

Upvotes: 0

Views: 2682

Answers (1)

AlexN
AlexN

Reputation: 2554

Actually, I don't think it's possible. Of course you can override onBackPressed method of the Activity so user will not be able to navigate back. Also you can set FullScreenMode to hide status bar from user. However, that's very hard to intercept Home key. It's by Android design, so user will always be able to go to the HomeScreen.

So generally, I would recommend using ProgressDialog reference here , you can even setCancelable(false) to prevent it being dismissed by "Back" but "Home" will still minimize your app and go back to the homescreen.

Upvotes: 2

Related Questions