Hello,
according to this
article I've added the new intent on back button pressed action for android app. But nothing happend when I'm on single application Kiosk mode when I press back button.
My application is .net MAUI application and for android platform I have used follwoing code:
- static bool OnBackPressed(IServiceProvider serviceProvider, Activity activity)
- {
- var intent = new Intent();
- intent.SetComponent(new ComponentName("com.manageengine.mdm.android", "com.manageengine.mdm.framework.customsettings.WifiPickerActivity"));
- intent.SetFlags(ActivityFlags.ResetTaskIfNeeded);
- try
- {
- activity.ApplicationContext.StartActivity(intent);
- return true;
- }
- catch (Exception exc)
- {
- var logger = serviceProvider.GetRequiredService<ILogger<IViewModel>>();
- logger.LogError(exc, "Failed to send intent to activate Custom Settings");
- }
- return false;
- }
OnBackPressed event is registered using following code:
- builder.ConfigureLifecycleEvents((sp, events) =>
- {
- events.AddAndroid(sp, (serviceProvider,android) =>
- {
- android
- .OnBackPressed(activity => OnBackPressed(serviceProvider, activity))
- .OnCreate((activity, bundle) => OnCreate(serviceProvider, activity.ApplicationContext))
- .OnDestroy(activity => OnDestroy(activity.ApplicationContext));
- });
- });
Is it necessary to do something else? Or is there something wrong in my code?
Thank you for your answers.