I have a rather basic React Native app. I want to conditionally lock/unlock the app based on the component that is being rendered. For example, I want to lock the app (in kiosk mode) if the Player
component is rendered and then unlock the app if it's not (or unmounting).
render(){
return(
<>
{this.state.showPlayer === false && <Connect />}
{this.state.showPlayer === true && <Player />}
</>
)
}
I have reviewed the documentation for setting the lock here: https://developer.android.com/work/dpc/dedicated-devices/lock-task-mode#start_lock_task_mode
Here is the code:
// Set an option to turn on lock task mode when starting the activity.
ActivityOptions options = ActivityOptions.makeBasic();
options.setLockTaskEnabled(true);
// Start our kiosk app's main activity with our lock task mode option.
PackageManager packageManager = context.getPackageManager();
Intent launchIntent = packageManager.getLaunchIntentForPackage(KIOSK_PACKAGE);
if (launchIntent != null) {
context.startActivity(launchIntent, options.toBundle());
}
I am not sure how to configure this as I'm rather new to the React Native and Android space. Any help would be appreciated.
from React Native Kiosk Mode
No comments:
Post a Comment