0

I am working on a mobile app using xamarin forms, is it possible to detect swipe gesture in android for screenshot or click of lock screen or home screen ?

If it is possible via objective C/swift/java then it would also be possible through Xamarin.

TheDeveloper
  • 1,127
  • 1
  • 18
  • 55
  • iOS: http://stackoverflow.com/questions/14352228/is-there-a-away-to-detect-the-event-when-ios-device-goes-to-sleep-mode-when-the – SushiHangover Oct 20 '16 at 15:40

1 Answers1

1

Android

I do not believe you can setup a swipe gesture / click during the Lock Screen as it's a separate Activity in a different process(System app). You also can't replace the lock screen with a user application.

You can control some of this via the Device Admin API:

https://developer.android.com/guide/topics/admin/device-admin.html#lock

However that's only for the opposite of what you want(Probably to know if the user finished the lock screen).

You can instead listen for the ACTION_USER_PRESENT or the fairly new ACTION_USER_UNLOCKED broadcast via a Broadcast Receiver:

https://developer.android.com/reference/android/content/Intent.html#ACTION_USER_PRESENT (API 3)

https://developer.android.com/reference/android/content/Intent.html#ACTION_USER_UNLOCKED (API 24)

https://developer.android.com/training/articles/direct-boot.html#notification

iOS

You can use Darwin Notifications - https://developer.apple.com/reference/corefoundation/1666719-cfnotificationcenter

You can check the following events:

  • com.apple.springboard.hasBlankedScreen - When the screen goes blank (One of a few times it will)
  • com.apple.springboard.lockstate - What state the lock is in(locked/unlocked)
  • com.apple.springboard.lockcomplete - The device locked

Is there a away to detect the event when iOS device goes to sleep mode (when the screen gets blackened)?

Lock Unlock events iphone

Community
  • 1
  • 1
Jon Douglas
  • 13,006
  • 4
  • 38
  • 51
  • Hi Jon, I wanted swipe gesture for android before lock just to know if they are trying to screenshot the screen and lock button or home button on apple to know if they are trying to screenshot. I think Darwin notifications would help for iOS but can you shed some light for android's swipe gesture on active screen not locked screen ? – TheDeveloper Oct 20 '16 at 16:49
  • http://stackoverflow.com/questions/29621903/detect-only-screenshot-with-fileobserver-android – Yuri S Oct 20 '16 at 17:20