【问题标题】:Is it possible to take screenshot in unrooted android phone.? [duplicate]是否可以在无根的Android手机中截屏。? [复制]
【发布时间】:2015-09-17 13:29:20
【问题描述】:

我正在开发一个应用程序,其中有一个单击该按钮的按钮我想要 android 屏幕的屏幕截图,而不是我的手机没有根的应用程序屏幕。没有root的手机可以截图吗?

【问题讨论】:

标签: android screenshot


【解决方案1】:

是的,这是可能的。

看看Android Screenshot Library

Android 屏幕截图库 (ASL) 能够以编程方式从 Android 设备捕获屏幕截图,而无需拥有 root 访问权限。相反,ASL 使用在后台运行的本机服务,每次设备启动时通过 Android 调试桥 (ADB) 启动一次。

如何实现?

修改清单 XML

为了使 Android 服务可以访问,请将以下声明添加到您的客户端应用程序的 XML 清单中:

<service android:name="pl.polidea.asl.ScreenshotService">
    <intent-filter>
            <action android:name="pl.polidea.asl.ScreenshotService.BIND" />
            <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</service>

绑定服务

要获得 IScreenshotProvider 接口,必须使用 Context.bindService 绑定到 ASL 服务 (pl.polidea.asl.ScreenshotService) - 例如:

// (using class name)
Intent intent = new Intent();
intent.setClass (this, pl.polidea.asl.ScreenshotService.class);
bindService (intent, aslServiceConnection, Context.BIND_AUTO_CREATE);

参考文献

【讨论】:

  • 如何在android studio中使用这个库?
  • 它有java项目。所以你可以用 Android Studio 构建它
猜你喜欢
  • 2022-08-16
  • 2014-03-18
  • 2012-08-23
  • 1970-01-01
  • 2013-03-10
  • 1970-01-01
  • 1970-01-01
  • 2014-04-13
  • 2019-10-25
相关资源
最近更新 更多