资源简介
android 截屏demo,详细的源码
代码片段和文件信息
package pl.polidea.asl;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.*;
import java.nio.*;
import java.security.InvalidParameterException;
import java.util.List;
import java.util.UUID;
import android.app.Service;
import android.app.ActivityManager;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap.Config;
import android.graphics.Matrix;
import android.os.*;
import android.util.Log;
import android.view.*;
public class ScreenshotService extends Service {
/*
* Action name for intent used to bind to service.
*/
public static final String BIND = “pl.polidea.asl.ScreenshotService.BIND“;
/*
* Name of the native process.
*/
private static final String NATIVE_PROCESS_NAME = “asl-native“;
/*
* Port number used to communicate with native process.
*/
private static final int PORT = 42380;
/*
* Timeout allowed in communication with native process.
*/
private static final int TIMEOUT = 1000;
/*
* Directory where screenshots are being saved.
*/
private static String SCREENSHOT_FOLDER = “/sdcard/screens/“;
/*
* An implementation of interface used by clients to take screenshots.
*/
private final IScreenshotProvider.Stub mBinder = new IScreenshotProvider.Stub() {
@Override
public String takeScreenshot() throws RemoteException {
try {
return ScreenshotService.this.takeScreenshot();
}
catch(Exception e) { return null; }
}
@Override
public boolean isAvailable() throws RemoteException {
return isNativeRunning();
}
};
@Override
public void onCreate() {
Log.i(“service“ “Service created.“);
}
@Override
public IBinder onBind(Intent intent) {
return mBinder;
}
/*
* Checks whether the internal native application is running
*/
private boolean isNativeRunning() {
try {
Socket sock = new Socket();
sock.connect(new InetSocketAddress(“localhost“ PORT) 10); // short timeout
}
catch (Exception e) {
return false;
}
return true;
// ActivityManager am = (ActivityManager)getSystemService(Service.ACTIVITY_SERVICE);
// List ps = am.getRunningAppProcesses();
//
// if (am != null) {
// for (ActivityManager.RunningAppProcessInfo rapi : ps) {
// if (rapi.processName.contains(NATIVE_PROCESS_NAME))
// // native application found
// return true;
// }
//
// }
// return false;
}
/*
* Internal class describing a screenshot.
*/
class Screenshot {
public Buffer pixels;
public int width;
public int height;
public int bpp;
public boolean isValid() {
if (pixels == null || pixels.capacity() == 0 || pixels.limit() == 0) return false;
if (width <= 0 || height <= 0) return false;
return true;
}
}
/*
* Determines whether the phone‘s screen is rotated.
*/
private int getScree
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-09-01 02:33 鎴睆\
目录 0 2011-10-13 08:55 鎴睆\demo\
目录 0 2011-10-13 08:55 鎴睆\demo\.settings\
目录 0 2011-01-03 06:30 鎴睆\demo\src\
目录 0 2011-01-03 06:30 鎴睆\demo\res\
目录 0 2011-09-01 02:39 鎴睆\demo\gen\
目录 0 2011-10-13 09:20 鎴睆\demo\bin\
目录 0 2011-01-03 06:30 鎴睆\demo\assets\
目录 0 2011-01-03 06:30 鎴睆\demo\src\pl\
目录 0 2011-01-03 06:30 鎴睆\demo\res\values\
目录 0 2011-01-03 06:30 鎴睆\demo\res\layout\
目录 0 2011-01-03 06:30 鎴睆\demo\res\drawable-mdpi\
目录 0 2011-01-03 06:30 鎴睆\demo\res\drawable-ldpi\
目录 0 2011-01-03 06:30 鎴睆\demo\res\drawable-hdpi\
目录 0 2011-09-01 02:39 鎴睆\demo\gen\pl\
目录 0 2011-10-13 09:00 鎴睆\demo\bin\pl\
目录 0 2011-01-03 06:30 鎴睆\demo\src\pl\polidea\
目录 0 2011-09-01 02:39 鎴睆\demo\gen\pl\polidea\
目录 0 2011-10-13 09:00 鎴睆\demo\bin\pl\polidea\
目录 0 2011-01-03 06:30 鎴睆\demo\src\pl\polidea\asl\
目录 0 2011-10-13 09:00 鎴睆\demo\gen\pl\polidea\asl\
目录 0 2011-10-13 09:00 鎴睆\demo\bin\pl\polidea\asl\
目录 0 2011-01-03 06:30 鎴睆\demo\src\pl\polidea\asl\demo\
目录 0 2011-10-13 09:00 鎴睆\demo\gen\pl\polidea\asl\demo\
目录 0 2011-10-13 09:00 鎴睆\demo\bin\pl\polidea\asl\demo\
文件 8169 2011-01-03 02:44 鎴睆\ScreenshotService.java
文件 893 2011-01-03 03:39 鎴睆\run.sh
文件 1886 2011-01-03 03:37 鎴睆\run.ps1
文件 799 2011-01-03 03:37 鎴睆\run.bat
文件 345 2010-08-23 07:04 鎴睆\readme.html
文件 415 2010-08-20 05:00 鎴睆\IScreenshotProvider.aidl
............此处省略37个文件信息
- 上一篇:javamail实现邮件收发和加密
- 下一篇:android 火车票查询源代码
相关资源
- android 火车票查询源代码
- 有关Android中从图库或拍照获取头像并
- Android项目实战--通讯录
- Android-Delphi开发蓝牙官方解析(XE10+小
- Android之利用WebBrowser实现浏览器
- Android之程序界面内截取屏幕
- 自己做的android通讯录
- Retrofit2最新视频教程
- android开机自动启动service
- Android 备份(提取)apk
- Android 登录界面Demo源码推荐
- Android 微信摇骰子
- Android更新(兼容7.0文件,支持5.0通知
- 基于Android的网上订餐系统
- 安卓Android的英语学习助手毕业设计源
- Android OpenSSL调试通过
- Android颜色选取圆盘Demo代码
- android实现摇一摇功能
- 自定义Android中TabHost组件显示在屏幕底
- PacketSender源码Android Studio版
- 你画我猜源码
- android仿新浪微博应用
- Android组件化大牛视频
- Android实现时钟组件时钟、闹钟、计时
- Android酷天气源代码全
- jdk12百度网盘地址
- android日历源代码
- Android音频实时传输与播放--客户端
- 简易计算器源代码
- Android 自动批量生成联系人 APK
评论
共有 条评论