LoginSignup
5
6

More than 5 years have passed since last update.

iOS・Androidのスクショを検知・無効化する方法

Posted at

snapchat的な

iOS

検知

ViewController.swift
import UIKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        NotificationCenter.default.addObserver(self, selector: #selector(didScreenshot), name: .UIApplicationUserDidTakeScreenshot, object: nil)
    }

    func didScreenshot(notification: Notification) {
        print("didScreenshot")
    }
}

Android

無効化

MainActivity.java
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6