android5.0 截屏,ScreenRecord库用于在android 5.0以上的设备进行截屏

ScreenRecordLibrary

Intro

ScreenRecord library is used to capture screen for devices with android 5.0 and above. It used the latest Media Projection API exposed by android since API level 21.

Demo

If you want to use this library in your code, you can download the project, and refer to app module in the code.

If you just want to use this Screen Record Tool, you can download it from google play or 应用宝

Usage

This library is uploaded to sonatype, you can use it following these steps:

1. add sonatype repository in your build.gradle

allprojects {

repositories {

jcenter()

mavenCentral()

maven {

url 'https://oss.sonatype.org/content/groups/public'

}

}

need to compile this library

compile 'com.github.charlesjean:recordlibrary:0.0.2'

after you acquire media projection permission from user, you need to start screen record service with the following code

Intent intent = new Intent(this, RecordService.class);

int width = ParameterManager.getInstance(this).getVideoWidth();

int height = ParameterManager.getInstance(this).getVideoHeight();

boolean needAudio = ParameterManager.getInstance(this).needAudio();

boolean isLandScapeMode = ParameterManager.getInstance(this).isLandScapeModeOn();

int quality = ParameterManager.getInstance(this).getVideoQuality();

intent.putExtra(RecordConst.RECORD_INTENT_RESULT, resultCode);

intent.putExtra(RecordConst.RECORD_DATA_INTENT, data);

intent.putExtra(RecordConst.KEY_RECORD_SCREEN_WITH, width);

intent.putExtra(RecordConst.KEY_RECORD_SCREEN_HEIGHT, height);

intent.putExtra(RecordConst.KEY_RECORD_NEED_AUDIO, needAudio);

intent.putExtra(RecordConst.KEY_RECORD_IS_LANDSCAPE, isLandScapeMode);

intent.putExtra(RecordConst.KEY_VIDEO_QUALITY, quality);

intent.putExtra(RecordConst.KEY_VIDEO_DIR, getResources().getString(R.string.save_dir));

intent.putExtra(RecordConst.KEY_NOTIFICATION_ICON, R.drawable.ic_launcher);

startService(intent);

For more detail, you can refer to the demo project.

License

This library is under Apache License, Version 2.0, not including the demo project.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值