资源简介
Android 后台Service 实现录像,无页面
代码片段和文件信息
package com.uiot.smarthome.server;/**
import android.app.Notification;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.hardware.Camera;
import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.os.Environment;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.text.format.DateFormat;
import android.view.Gravity;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.WindowManager;
import java.util.Date;
/**
* @描述 (测试程序可实现后台录像)
* @date 2016/8/15 0015 8:28
*/
public class BackgroundVideoRecorder extends Service implements SurfaceHolder.Callback {
private WindowManager windowManager;
private SurfaceView surfaceView;
private Camera camera = null;
private MediaRecorder mediaRecorder = null;
@Override
public void onCreate() {
// Start foreground service to avoid unexpected kill
Notification notification = new Notification.Builder(this)
.setContenttitle(“Background Video Recorder“)
.setContentText(““)
.setSmallIcon(R.drawable.button_selector)
.build();
startForeground(1234 notification);
// Create new SurfaceView set its size to 1x1 move it to the top left corner and set this service as a callback
windowManager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
surfaceView = new SurfaceView(this);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
1 1
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
PixelFormat.TRANSLUCENT
);
//全屏显示在最上图层上
// final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
// WindowManager.LayoutParams.WRAP_CONTENT
// WindowManager.LayoutParams.W
相关资源
- petsas_rage_against_the_virtual_machine.pdf
- 酷派刷机Android_Download_客服专用_V1.1
- Androidstudio证书文件.zip
- android 自定义 模仿Launcher
- android根据经纬度获取地址
- android动态添加删除组件Layout
- android TCP server 和TCP client通信源码
- unity移动端截图后保存至相册
- android-support-multidex1.0.1.jar
- android-opencv已经编译好的JAR库
- Android读取文本文件的demo
- apkutil解析apk安装包的工具
-
音乐播发器界面 xm
l - Android声波通信改进版
- Android+SDK+2.0+与安装教程
-
Android MediaPla
yer与Http Proxy结合之优化 -
玩转 Android MediaPla
yer之视频预加载 -
Android MediaPla
yer与Http Proxy结合之基础 - android 图片管理器
- android自定义全键盘随机包含字母+标点
- 这是一个简单的Android小程序,实现增
- pedometer计步器源码
- Android利用广播实现耳机的线控
- android4.4 DhcpInfoInternal.java
- Android Opencv 人脸识别
- android底部菜单栏demo230129
- Android计数小demo
- 基于Android的网上购物系统
- android仿微信app应用
- android-Sqlite建多张表-增删改查操作
评论
共有 条评论