how to implement Lock Task Mode in xamarin application

XamarinInn 1 Reputation point
2022-05-19T10:41:43.167+00:00

My client want to use my application in a android Mobile Tab device.
client just want to keep it as a single app device.
This tab will be placed in a hospital and patients are allowed to use my app.
So we should not allow the user to minimise the app or we should not allow the user to exit from the application.

The existing app is a normal application that is already used in android and ios devices.

What we can do for that ?

https://learn.microsoft.com/fr-fr/dotnet/api/android.app.activity.startlocktask?view=xamarin-android-sdk-12&viewFallbackFrom=xamarin-android-sdk-9

I have seen a startlockTask concept from the above link,but i couldnt understand how to use it in my app.

Please help me with your seggestions.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,295 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,656 Reputation points Microsoft Vendor
    2022-05-20T07:31:26.243+00:00

    Hello,​

    If you want to use startlockTask like this thread: https://learn.microsoft.com/fr-fr/dotnet/api/android.app.activity.startlocktask?view=xamarin-android-sdk-12&viewFallbackFrom=xamarin-android-sdk-9

    Just add StartLockTask(); method in the OnCreate method of MainActivity.cs.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.