0

enter image description hereI will like to return true or false if TalkBack is active.

public bool IsVoiceOver() {

     AccessibilityManager am = (AccessibilityManager) 
     Context.AccessibilityService;

        var a =  am.IsEnabled;
        if (!a) 
        {
            Console.WriteLine(" DROID voice over   is : " + a);
            return false;
        }
        else 
        {
            Console.WriteLine("DROID voice over  is : " + a);
        return true;
        }
    }

However, "AccessibilityManager" is not working. I guess is a syntax issue not sure.

Pxaml
  • 651
  • 2
  • 12
  • 38

1 Answers1

1

What you can do is check with the AccessibilityManager if this is available or not

Something like below:

 AccessibilityManager am = (AccessibilityManager)GetSystemService(Context.AccessibilityService);

 if (am.IsEnabled) 
    {
        Console.WriteLine(" DROID voice over is active);
        return am.IsEnabled;
    }
    else 
    {
        Console.WriteLine("DROID voice over is inactive);
        return am.IsEnabled;
    }

do not forget to add the following using statements:

using Android.Views.Accessibility;
using Android.Content;

UPDATE

To access the GetSystemService method you will need the Current Activity Plugin

  • Install the NuGet package for it.

  • Simply call the Init method on OnCreate of your MainActivity CrossCurrentActivity.Current.Init(this, bundle);

  • Then you can call the GetSystemService Method as shown below:

      AccessibilityManager am = (AccessibilityManager)CrossCurrentActivity.Current.Activity.GetSystemService(Context.AccessibilityService);
    
FreakyAli
  • 13,349
  • 3
  • 23
  • 63
  • Please see the screenshot on my original code. got an issue on GETSYSTEMSERVICE is this part of the os or is just a name of any other method? and the usings are included already. Thank you – Pxaml Feb 22 '19 at 16:26
  • 1
    You need activity reference for this you need to use it with current activity eg `Activity.GetSystemService()` – FreakyAli Feb 22 '19 at 18:25
  • You .got it !! Thank you so much – Pxaml Feb 23 '19 at 03:00
  • @Pxaml if this answers your question kindly mark it as correct – FreakyAli Feb 23 '19 at 05:03
  • G. hakim can you please take a look of this question https://stackoverflow.com/questions/55521746/how-to-find-if-user-has-enrolled-any-fingerprints?noredirect=1#comment97748133_55521746 – Pxaml Apr 04 '19 at 17:43