https://datatheorem.github.io/android/2014/12/26/android-screencapture/

https://www.youtube.com/watch?v=tT1XSoykjtA

ANDROID LOLLIPOP SCREEN CAPTURE AND SHARING

Android Lollipop has a new feature that allows screen capturing and screen sharing from third party applications. The feature allows third party apps to capture videos from the device and deliver it over the network.

Screen capturing does not require any pre-defined permissions; however, it does require user consent, as shown in the image below. If the user agrees to the consent, which does not necessarily explain the permanence of the feature nor its broad range, the application is able to capture everything that is displayed on the device’s screen, including sensitive activity from all other apps, such as password keystrokes, credit card screens, home addresses, etc. The capturing ability remains on even if the user terminates/closes the app, but not after a reboot. Additionally, when an application is performing screen capturing a small screen casting icon is displayed in the notification bar. This does not give the user enough information to make an informed decision on whether to disable casting.

Please click here to view the full step-by-step demo. Thanks Alexey Reznik for creating an informative video.

Fig:SideScreen is a 3rd Party Application on Google Play

Since a user may not understand the impact of its consent, mobile apps should proactive protect their sensitive screens from third party screen capturing and sharing. This is possible using the FLAG_SECURE option on any given screen. The following code shows an example:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE)


}

However, if the developers want to protect all the screens of their applications from third party screen capturing and sharing, they need to use this flag in each of the Activities separately. There is no global means to set this flag for all the screens at once. But, one can design their applications in such a way that the FLAG_SECURE needs to be used only once. Below is the code snippet:

  • Define a BaseActivity and set the FLAG_SECURE in that Activity :
public class BaseActivity extends Activity {

    @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/**
* approach 1: create a base activity and set the FLAG_SECURE in it,
* Extend all other activities, Fragments from this activity
*/
getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE);
}
  • Take this BaseActivity as superclass for all the other Activities.
public class LoginActivity extends BaseActivity
public class MainActivity extends BaseActivity

By doing so, when the onCreate() method of the super class is overrriden, the FLAG_SECURE automatically gets set for all the child activities.

  • There might be cases where one wants to unset the FLAG_SECURE for some screens. In such cases, in child activity can use the below code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
clear flags: It can be used when user need to enable screen capturing in some applications
*/
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}

More information on FLAG_SECURE API can be found here: FLAG_SECURE

【转】ANDROID LOLLIPOP SCREEN CAPTURE AND SHARING的更多相关文章

  1. SPX Instant Screen Capture

    Today I will recommend a NICE screen capture tool, which name is SPA Instant Screen Capture. http:// ...

  2. Android(Lollipop/5.0) Material Design(六) 使用图像

    Material Design列 Android(Lollipop/5.0)Material Design(一) 简单介绍 Android(Lollipop/5.0)Material Design(二 ...

  3. ffmpeg 录屏 screen capture recorder

    ffmpeg在Linux下用X11grab进行屏幕录像,在Windows下用DirectShow滤镜 首先需要安装一个软件,screen capture recorder 编译好的下载地址是: htt ...

  4. Android(Lollipop/5.0) Material Design(二) 入门指南

    Material Design系列 Android(Lollipop/5.0)Material Design(一) 简介 Android(Lollipop/5.0)Material Design(二) ...

  5. Android(Lollipop/5.0) Material Design(一) 简单介绍

    Material Design系列 Android(Lollipop/5.0)Material Design(一) 简单介绍 Android(Lollipop/5.0)Material Design( ...

  6. Android(Lollipop/5.0) Material Design(四) 创建列表和卡片

    Material Design系列 Android(Lollipop/5.0)Material Design(一) 简单介绍 Android(Lollipop/5.0)Material Design( ...

  7. full page screen capture in js

    full page screen capture in js html2canvas https://html2canvas.hertzen.com/ https://github.com/nikla ...

  8. Android Lollipop 5.0 经典新特性回顾

    *Tamic 专注移动开发! 更多文章请关注 http://blog.csdn.net/sk719887916 虽然Android已到了7.0 ,但是我们还是不能忘怀视觉革命性改变的5.0,今天回顾下 ...

  9. Android(Lollipop/5.0) Material Design(一) 简介

    官网地址:https://developer.android.com/intl/zh-tw/design/material/index.html 使用Material Design 需要api21,即 ...

随机推荐

  1. git push到远程仓库

    (此处我以码云为例) 常用命令: 添加远程仓库:git remote add origin 仓库地址 (origin只是一个名字,对远程仓库的一个名字,习惯上用origin) 从仓库拉取内容:git ...

  2. Proteus 8使用 1新建一个Proteus工程

    新建一个Proteus工程 下一步 创建部分结束,可以看到两部分-->原理图与源代码. 首先按下F7或从“构建”菜单中选择“构建工程” 之后切换到原理图窗口 按下F12或点击窗口最左下角的“运行 ...

  3. MySQL--->存储引擎及图形化工具

    本章目标: 掌握MySQL存储引擎的特点 掌握Navicat图形化工具的使用 了解其他的一些图形化管理工具 1.存储引擎种类: 2. 表级锁和行级锁: 3.常见的引擎: InnoDB 存储引擎 MyI ...

  4. Java高级篇反射和注解

    反射是什么? 反射的作用?能带来什么好处? 反射的使用? 注解的使用? 注解和反射配合实战...

  5. 使用pytorchviz进行模型可视化出现 'NoneType' object has no attribute 'grad_fn'

    问题 最近学习pytorch, 原来用kreas重现的模型改为用pytorch实现训练,因为这样给模型的操作更加细致, 对模型的掌控更好. 当我写好一个模型 出现了这个问题 使用pytorchviz进 ...

  6. Java基于SSM的个人博客系统(源码 包含前后台)

    @ 目录 系统简介 系统运行截图 核心代码 写在最后 系统简介 技术点:Java.JSP.SSM框架,实现了个人博客系统 用户角色分为:普通用户.管理员.系统管理员 功能:发博客.博客分类.博客删除. ...

  7. Nordic52840SDK学习之定时器

    Nordic 52840 SDK学习之定时器 今天开始学习52840SDK,特在此处记录学习内容,防止以后忘记,或许可以给以后的初学者提供一些帮助.如有错误,请发邮件至843036544@qq.com ...

  8. linux驱动之模块化编程小总结

    本文包含了linux驱动模块化编程的基本,包括创建多线程,延时,以及makefile 以一个实例来说明 #include<linux/init.h> #include<linux/m ...

  9. docker flannel网络部署和路由走向分析

    1.flannel介绍 flannel是coreos开发的容器网络解决方案.flannel为每个host分配一个subnet,容器从此subnet中分配ip.这些ip可以在host间路由,容器间无需n ...

  10. ftp 搭建 centos 源

    1.  yum -y install vsftpd* 2.  /etc/init.d/vsftpd restart 3.  mount CentOS-7-aarch64-Everything-1810 ...