0

I am trying to restrict Location Spoofing.

For API <= 22 it works fine but >22 it asking for permissions and **ALLOW_MOCK_LOCATION ** is deprecated.

So need solution for this

Sanket Parchande
  • 894
  • 9
  • 14
  • Possible duplicate of [How to check for Mock Location in Android Marshmallow?](https://stackoverflow.com/questions/32668494/how-to-check-for-mock-location-in-android-marshmallow) – Michael Jul 07 '17 at 12:17
  • @Michael I tried those things but cannot get solution. – Sanket Parchande Jul 07 '17 at 12:20
  • It's unclear what you mean by _"cannot get solution"_. – Michael Jul 07 '17 at 12:23
  • Above API 22 ,I am not able to detect whether Mock Location is Used or not due to permissions. I got SercurityException while following Code AppOpsManager opsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); // boolean isMockLocation = (opsManager.checkOp(AppOpsManager.OPSTR_MOCK_LOCATION, android.os.Process.myUid(), BuildConfig.APPLICATION_ID)== AppOpsManager.MODE_ALLOWED); // return isMockLocation; – Sanket Parchande Jul 07 '17 at 12:27
  • Why not just use `location.isFromMockProvider()` as was suggested on the page I linked to? – Michael Jul 07 '17 at 12:42
  • It returning false even if I Select fake gps App in Mock Location at "Developer Option" – Sanket Parchande Jul 07 '17 at 12:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/148606/discussion-between-sanket-parchande-and-michael). – Sanket Parchande Jul 07 '17 at 12:51

0 Answers0