package com.android.ScreenCap;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.media.ToneGenerator;
import android.net.Uri;
import android.os.IBinder;
import android.util.Log;
public class ScreenCapService extends Service {
private static final String TAG = "ScreenCapService";
private static final String ACTION_CAPTURE_SCREEN =
"com.android.CAPTURE_SCREEN";
private BroadcastReceiver mCaptureScreenReceiver;
private ToneGenerator mToneGenerator;
@Override
public void onCreate() {
/* capture screen receiver */
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_CAPTURE_SCREEN);
mCaptureScreenReceiver = new CaptureScreenReceiver();
registerReceiver(mCaptureScreenReceiver, filter);
/* capture tone */
initializeCaptureTone();
}
@Override
public void onDestroy() {
unregisterReceiver(mCaptureScreenReceiver);
releaseCaptureTone();
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
private final class CaptureScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_CAPTURE_SCREEN.equals(intent.getAction())) {
Log.d(TAG, "CaptureScreenReceiver: " + intent.getAction());
ToneGenerator tg = mToneGenerator;
if (tg != null) {
tg.startTone(ToneGenerator.TONE_PROP_BEEP);
}
String file_name = ScreenCapNative.startCaptureScreen();
if (file_name != null) {
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
Uri.parse("file://" + file_name)));
Log.d(TAG, "CaptureScreen as file: " + file_name);
}
}
}
}
private void initializeCaptureTone() {
// Initialize tone generator.
try {
mToneGenerator = new ToneGenerator(
AudioManager.STREAM_SYSTEM, 100);
} catch (Throwable ex) {
Log.w(TAG, "Exception caught while creating tone generator: ", ex);
mToneGenerator = null;
}
}
private void releaseCaptureTone() {
if (mToneGenerator != null) {
mToneGenerator.release();
mToneGenerator = null;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ScreenCap-zmyde2010-csdn.rar (14个子文件)
libscreencapjni.so 5KB
ScreenCap.apk 16KB
ScreenCap
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
values
strings.xml 165B
drawable-mdpi
ic_launcher.png 3KB
layout
main.xml 398B
jni
Android.mk 594B
com_android_ScreenCap_ScreenCapNative.cpp 3KB
Android.mk 358B
src
com
android
ScreenCap
ScreenCapNative.java 2KB
ScreenCapReceiver.java 474B
ScreenCapService.java 3KB
AndroidManifest.xml 830B
共 14 条
- 1
zmyde2010
- 粉丝: 237
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页