Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by tessellation · Dec 28, 2017 at 08:10 PM · androidnativegestures

Can the accessibility “Magnification Gesture” be detected on Android?

My game sometimes requires repeated tapping. Some players are complaining that it doesn't work when they have the "triple tap to zoom" accessibility gesture system setting enabled on their device.

Web search showed me that it can't be disabled during gameplay, but can it be detected? At least then I can explain to users how to turn it off while playing.

I'm not sure which android API I could use to check this setting. I'm not a native android developer and Google isn't turning up much. Help is much appreciated!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by tessellation · Dec 30, 2017 at 08:48 AM

I figured this out. Here's the code to do it in Java:

 Settings.Secure.getInt( context.getContentResolver(), "accessibility_display_magnification_enabled" );

...just check the return value: 1 = enabled, 0 = disabled

Here's the code to do it in a Unity C# Script:

 public static bool CheckForSystemZoomEnabled()
 {
     #if UNITY_ANDROID
     try {
         using(AndroidJavaClass clsUnity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
         {
             AndroidJavaObject objActivity = clsUnity.GetStatic<AndroidJavaObject>("currentActivity");
             AndroidJavaObject objResolver = objActivity.Call<AndroidJavaObject>("getContentResolver");
             using(AndroidJavaClass clsSecure = new AndroidJavaClass("android.provider.Settings$Secure"))
             {
                 int val = clsSecure.CallStatic<int>("getInt", objResolver, "accessibility_display_magnification_enabled");
                 return val != 0;
             }
         }
     } catch(System.Exception) { }
     #endif
     return false;
 }
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image breban1 · Aug 22, 2018 at 02:22 AM 0
Share

@tessellation thanks SO much for this code!

Quick question: Do you know if this code can be called on older devices that don't support $$anonymous$$agnification? I currently allow very old OS and devices to run on my game and don't want to break them. Any help would be appreciated!

Thanks!

avatar image tessellation · Aug 22, 2018 at 09:04 PM 1
Share

@breban1 I don't see why not, if any Java class doesn't exist, it should throw an exception and the catch will hit and return false. But you should always test yourself if possible.

avatar image breban1 tessellation · Aug 22, 2018 at 09:14 PM 0
Share

It looks like it is working on my test devices, thanks again for posting your own answer!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

155 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Set android:hardwareAccelerated="true" for input field on Android 0 Answers

Android Native Camera Low Light/Low ISO 2 Answers

How to translate ArrayList to C# using AndroidJavaClass? 1 Answer

Can't access android mediastore 1 Answer

using shared libraries generated by Android project in Unity 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges