关于ddpush推动实现抖动视频的使用
/**
//开机之后打开服务 开机成功打开服务ddpushService
*
*/
<!-- 开机广播 -->
<receiver android:name="com.receiver.BootCompletedReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</receiver>
//打开开机启动服务
<service android:name="com.service.BootCompletedService" />
<service android:name="com.service.UpdateService" />
<!-- 常驻服务,避免杀死app -->
<service android:name="com.service.DDPushService" />
//为了确保服务不会被断网影响
/**
* 网络监听
* @author admin
*
*/
public class NetworkReceiver extends BroadcastReceiver {
private static final String TAG = NetworkReceiver.class.getSimpleName();
public NetworkReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
Tools.Log("网络变化");
if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
boolean hasNetWork = Tools.hasNetwork(context);
if (hasNetWork) {
Tools.startService(context,"RESET");
BaseApplication.initGTService();
// Tools.getAddress();
// 网络变化且有网
if (Tools.hasWifi(context)){
Tools.ShowToastTemporary(context,"网络变化>有网wifi");
}else {
Tools.ShowToastTemporary(context, "网络变化>有网4G");
}
// 如果以没登录,就执行登录
if (BaseApplication.user==null){
BaseApplication.login();
}
}else { // 网络断开连接
Tools.ShowToastTemporary(context, "网络变化>没有网");
BaseApplication.upDataPushIdSucceed = false;
}
}
else {
//只要打开有网络 就运行ddpushservice
boolean hasNetWork = Tools.hasNetwork(context);
if (hasNetWork) {
Intent it = new Intent(context, DDPushService.class);
it.putExtra("CMD", "start_service");
context.startService(it);
it = null;
}
}
}
//抖动视频处理
//在没有打开应用用通知的形式发送通知
else if ("020".equals(code)) {
//查看车机抖动视频
videoName = JsonParser.getShakeVideoName(text);
if (!"com.icarphone".equals(Tools.getTopActivityPackageName(context))) {
LogUtils.v(TAG, "020 com.icarphone is not top Activity package");
int icon = R.drawable.ic_launcher;
String tickerText = "您有一条抖动视频!";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
contentView.setImageViewResource(R.id.image, R.mipmap.app);
contentView.setTextViewText(R.id.text, "您收到了一条抖动视频,请注意查看!");
notification.contentView = contentView;//
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.putExtra(MainActivity.P_VIDEO_NAME, videoName);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.contentIntent = contentIntent;
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.notify(mId++, notification);
//消息处理
int newMsg = UtilSharedPreference.getIntValue(context, Constants.MESSAGE_NUMBER);
newMsg++;
UtilSharedPreference.saveInt(context, Constants.MESSAGE_NUMBER, newMsg);
} else {
//如果应用打开直接跳出弹框
//查看车机抖动视频
LogUtils.v(TAG, "020 com.icarphone is top Activity package");
shakeCarPush(videoName);
}
MsgBean mb = new MsgBean();
mb.curMis = System.currentTimeMillis();
mb.displayName = "您收到了一条抖动视频,请点击查看!";
mb.fileName = videoName;
mb.cmd = code;
mDbHelper.save(mb);
mb = null;
}
//弹出弹框打开视频
private void shakeCarPush(final String videoName) {
Activity act = getCurrentActivity();
LogUtils.v(TAG, "shakeCarPush activity = " + act.getLocalClassName());
final Dialog sendDia = new Dialog(act);
View v = LayoutInflater.from(act).inflate(R.layout.shake_alarm, null);
tv_data = (TextView) v.findViewById(R.id.tv_data);
btn_video = (Button) v.findViewById(R.id.btn_video);
btn_video.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
if (sendDia!= null)
sendDia.dismiss();
//获取抖动视频
postToShakeVideo(videoName);
} catch (Exception e) {
e.printStackTrace();
}
}
});
String recTime = Tools.getTimeDetailes(System.currentTimeMillis());
tv_data.setText(recTime);
sendDia.requestWindowFeature(Window.FEATURE_NO_TITLE);
sendDia.setContentView(v);
Window window = sendDia.getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
window.setGravity(Gravity.CENTER);
//WindowManager windowManager = getCurrentActivity().getWindow().getWindowManager();
//Display display = windowManager.getDefaultDisplay();
WindowManager.LayoutParams params = window.getAttributes();
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.width = getScreenWidth(this);
window.setAttributes(params);
sendDia.show();
}
//获取最后压入寨的act
private Activity getCurrentActivity() {
Activity act = BaseActivity.currentActivity();
//这里的act BaseActivity.currentActivity()==基类BaseActivity oncreat=this
String name = act.getLocalClassName();
LogUtils.v(TAG, "getCurrentActivity() act" + name);
return act;
}
//下载成功 播放视频
else if ("021".equals(code)) {
LogUtils.v(TAG, " msg code = 021");
handler.removeMessages(MSG_COUNTER);
if(null == dialog || (null!=dialog && dialog.isShowing())) {
if (dialog != null)
dialog.dismiss();
String url = JsonParser.getShakeVideoUrl(text.trim());
MsgBean msgBean = new MsgBean();
msgBean.fileUrl = url;
msgBean.fileName = Utils.getUrlFileName(url);
msgBean.curMis = System.currentTimeMillis();
msgBean.cmd = code;
mDbHelper.saveShakeMsg(msgBean);
msgBean = null;
Intent dialogIntent = new Intent(getBaseContext(), ShakeVideoActivitys.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
dialogIntent.putExtra("url", url);
getApplication().startActivity(dialogIntent);
}
//点击通知 传videoName
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.putExtra(MainActivity.P_VIDEO_NAME, videoName);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.contentIntent = contentIntent;
/***
* 从消息页面点击消息会进入到MainActivity这个页面,根据Intent传入的参数处理
* @param it
*/
private void dealVideo(Intent it) {
String videoName = it.getStringExtra(P_VIDEO_NAME);
if (!TextUtils.isEmpty(videoName)) {
Intent serviceIt = new Intent(this, DDPushService.class);
serviceIt.putExtra("CMD", "99");
serviceIt.putExtra("videoName", videoName);
startService(serviceIt);
serviceIt = null;
}
}
@Override
protected void onNewIntent(Intent it) {
dealVideo(it);
super.onNewIntent(it);
}
//载mainActivity中启动service 防止被杀死
// 启动ddpservice,防止被杀死
DDPushStart.start(context);
//载ddpushStart中处理启动服务
public static void start(Context context) {
Intent startSrv = new Intent(context, DDPushService.class);
startSrv.putExtra("CMD", "RESET");
context.startService(startSrv);
}
else if (cmd.equals("RESET")) {
if (wakeLock != null && wakeLock.isHeld() == false) {
wakeLock.acquire();
}
//发送推送
resetClient();
//消息界面 接收到推送进行处理
lv_news.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (!isEdit) {
MsgBean n = news.get(position);
if (null == n)
return ;
if ("005".equals(n.cmd)) {
String FileUrl = n.fileUrl;
PhotoMsg photoMsg = new PhotoMsg();
photoMsg.setImageUrl(FileUrl);
List<PhotoMsg> list = new ArrayList<>();
list.add(photoMsg);
Bundle bundle = new Bundle();
bundle.putSerializable("list", (Serializable) list);
bundle.putInt("imgPos",0);
ScreenSwitch.startActivity(context, /*MessageGalleryActivity*/ImagePreviewActivity.class, bundle);
} else if ("021".equals(n.cmd) || "009".equals(n.cmd)) {
String FileUrl = n.fileUrl;
Bundle bundle = new Bundle();
bundle.putString("url", FileUrl);
ScreenSwitch.startActivity(context, ShakeVideoActivitys.class, bundle);
} else if ("020".equals(n.cmd)) {
Intent serviceIt = new Intent(context, DDPushService.class);
serviceIt.putExtra("CMD", "99");
serviceIt.putExtra("videoName", n.fileName);
startService(serviceIt);
serviceIt = null;
}
} else {
MsgBean n = news.get(position);
if (n.isSelected) {
n.isSelected = false;
} else {
n.isSelected = true;
}
if (isHasSel()) {
btnDelete.setBackgroundResource(R.mipmap.btn_white_nor);
} else {
btnDelete.setBackgroundResource(R.mipmap.btn_white_pre);
}
adapter.onReflush(context, news);
}
}
});
<!-- DDPUsh -->
<receiver android:name="com.service.DDPushTickAlarmReceiver" />
关于ddpush推动实现抖动视频的使用的更多相关文章
- Pr剪辑
目录 Pr剪辑教程 入门基础 创建序列类别 处理非正常序列 导出文件 导出设置 导入各类别素材 简单使用: 剪辑素材常用方法 剃刀工具 选择工具 波纹编辑工具 打入点和出点 剪辑速度 整个素材视频速度 ...
- 比年轻更年轻,快看能否接棒B站?
撰文 |懂懂 编辑 | 秦言 来源:懂懂笔记 背靠超新Z世代,快看能否接棒B站? 国漫什么时候能追上日漫? 国漫作者真能挣到钱吗? 国漫什么时候才能走向世界? 这是中国漫画从业者的"灵魂三问 ...
- TOP100summit2017:网易云通信与视频CTO赵加雨:外力推动下系统架构的4个变化趋势
壹佰案例:很荣幸邀请到您成为第六届壹佰案例峰会架构专场的联席主席,您曾深度参与Cisco Jabber,Webex Meeting, Cisco Spark等多项分布式实时通信类产品的架构与研发, ...
- WebRTC音视频引擎研究(1)--整体架构分析
WebRTC技术交流群:234795279 原文地址:http://blog.csdn.net/temotemo/article/details/7530504 1.WebRTC目的 ...
- WebRTC 视频对话
今天聊一下WebRTC.很多开发者,可能会觉得有些陌生,或者直接感觉繁杂.因为WebRTC在iOS上的应用,只是编译都让人很是头痛.这些话,到此为止,以防让了解者失去信心.我们只传播正能量,再多的困难 ...
- 转: WebRTC音视频引擎研究(1)--整体架构分析
转自: http://blog.csdn.net/temotemo/article/details/7530504 目录(?)[+] WebRTC技术交流群:234795279 原文地址:ht ...
- 「视频直播技术详解」系列之七:直播云 SDK 性能测试模型
关于直播的技术文章不少,成体系的不多.我们将用七篇文章,更系统化地介绍当下大热的视频直播各环节的关键技术,帮助视频直播创业者们更全面.深入地了解视频直播技术,更好地技术选型. 本系列文章大纲如下: ...
- 视频直播点播nginx-rtmp开发手册中文版
2016年8月18日12:42:35 参照官方文档https://github.com/arut/nginx-rtmp-module/wiki/Directives 请注意这个是粗翻译版,仅供参考,不 ...
- 用AE (Adobe After Effects) 处理视频
这话要从年会说起,我们组的年会节目需要一段场外亲友团的评价视频,于是我们就靠在公司门口的logo前拍了这么一段.但是呢,有很多的不理想: 画面抖动 杂音好烦(中午吃饭时拍的,还有好大的微波炉好了的声音 ...
随机推荐
- 单因素特征选择--Univariate Feature Selection
An example showing univariate feature selection. Noisy (non informative) features are added to the i ...
- Ubuntu 16.04 风扇特别响解决办法
主要原因是显卡驱动的问题,选择驱动专有,tested.
- open office操作word文档
前段时间工作需要使用open office往word中写文件,写图片,以及向footer也就是页尾中插入图片,已经封装成了类,直接调用即可,代码如下: package com.test.common. ...
- 关于QFTP乱码
// 从FTP接收的内容QString FtpUtil::_FromSpecialEncoding(const QString &InputStr){ #ifdef Q_OS_WIN retu ...
- Kylin Java RESTful API
最近在做大数据方面的开发, 学习研究了一段时间的kylin系统, 对于前端开发需要使用 RESTful API ,但是官网并没有提供详细的Java API. 经过几天的看文档,最终写出了 Java ...
- java io流 对文件夹的操作
java io流 对文件夹的操作 检查文件夹是否存在 显示文件夹下面的文件 ....更多方法参考 http://www.cnblogs.com/phpyangbo/p/5965781.html ,与文 ...
- c# 进程间的通信实现之一简单字符串收发
使用Windows API实现两个进程间(含窗体)的通信在Windows下的两个进程之间通信通常有多种实现方式,在.NET中,有如命名管道.消息队列.共享内存等实现方式,这篇文章要讲的是使用Wi ...
- cocos2dx day 3 - Chapter5 Scene
写在前面 越来越懒了,才3天,主要是cocos2dx官网的文章写的还是不是太完美,发现一段代码有个笔误,还有好几处写得不是很清楚的,所以有点泄气,不想继续读下去,不过为了我的第一款手游,一切困难都要先 ...
- vim入门过程
先下载了一本VIM的用户手册. 看到可以使用vimtutor(VIM的入门教程,很不错,由浅入深)作为入门. Unix系统中,请在命令行输入:vimtutor,进入教程. MS-Windows系统中, ...
- Struts2:MyEclippse中使用struts-default.xml中定义的拦截器(timmer,logger)
环境:MyEclipse 2015 Stable 2.0:struts2-core-2.3.16.1.jar等 struts.xml <struts> <package name=& ...