/**

  //开机之后打开服务  开机成功打开服务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推动实现抖动视频的使用的更多相关文章

  1. Pr剪辑

    目录 Pr剪辑教程 入门基础 创建序列类别 处理非正常序列 导出文件 导出设置 导入各类别素材 简单使用: 剪辑素材常用方法 剃刀工具 选择工具 波纹编辑工具 打入点和出点 剪辑速度 整个素材视频速度 ...

  2. 比年轻更年轻,快看能否接棒B站?

    撰文 |懂懂 编辑 | 秦言 来源:懂懂笔记 背靠超新Z世代,快看能否接棒B站? 国漫什么时候能追上日漫? 国漫作者真能挣到钱吗? 国漫什么时候才能走向世界? 这是中国漫画从业者的"灵魂三问 ...

  3. TOP100summit2017:网易云通信与视频CTO赵加雨:外力推动下系统架构的4个变化趋势

      壹佰案例:很荣幸邀请到您成为第六届壹佰案例峰会架构专场的联席主席,您曾深度参与Cisco Jabber,Webex Meeting, Cisco Spark等多项分布式实时通信类产品的架构与研发, ...

  4. WebRTC音视频引擎研究(1)--整体架构分析

    WebRTC技术交流群:234795279 原文地址:http://blog.csdn.net/temotemo/article/details/7530504     1.WebRTC目的     ...

  5. WebRTC 视频对话

    今天聊一下WebRTC.很多开发者,可能会觉得有些陌生,或者直接感觉繁杂.因为WebRTC在iOS上的应用,只是编译都让人很是头痛.这些话,到此为止,以防让了解者失去信心.我们只传播正能量,再多的困难 ...

  6. 转: WebRTC音视频引擎研究(1)--整体架构分析

    转自: http://blog.csdn.net/temotemo/article/details/7530504   目录(?)[+]   WebRTC技术交流群:234795279 原文地址:ht ...

  7. 「视频直播技术详解」系列之七:直播云 SDK 性能测试模型

    ​关于直播的技术文章不少,成体系的不多.我们将用七篇文章,更系统化地介绍当下大热的视频直播各环节的关键技术,帮助视频直播创业者们更全面.深入地了解视频直播技术,更好地技术选型. 本系列文章大纲如下: ...

  8. 视频直播点播nginx-rtmp开发手册中文版

    2016年8月18日12:42:35 参照官方文档https://github.com/arut/nginx-rtmp-module/wiki/Directives 请注意这个是粗翻译版,仅供参考,不 ...

  9. 用AE (Adobe After Effects) 处理视频

    这话要从年会说起,我们组的年会节目需要一段场外亲友团的评价视频,于是我们就靠在公司门口的logo前拍了这么一段.但是呢,有很多的不理想: 画面抖动 杂音好烦(中午吃饭时拍的,还有好大的微波炉好了的声音 ...

随机推荐

  1. nsq

    官网:http://nsq.io (1)描述 都是message broker,rabbitmq久经考验,nsq则是后起之秀.rabbitmq是erlang编写,nsq是golang. 安装:http ...

  2. zeromq:c,c++,golang及nodejs使用

    官网:www.zeromq.org 消息队列比较:http://www.cnblogs.com/charlesblc/p/6058799.html zeromq的一些观点:http://www.cnb ...

  3. Sql server 2008 R2 实现远程异地备份

    1. 环境: a)两台同样的Sql Server 2008 R2 服务器 b)操作系统都是windows 2008 c)需要将102.108.0.1数据库MSGC远程备份到112.118.0.2的服务 ...

  4. yii2的form表单样式怎么灵活控制呢?

    <?php $form = ActiveForm::begin(['id' => 'login-form', 'fieldConfig'=>[ 'template'=> &qu ...

  5. DataSet,DataTable与DataRow的复制方法

    DataSet 对象是支持 ADO.NET的断开式.分布式数据方案的核心对象 ,用途非常广泛.我们很多时候需要使用其中的数据,比如取得一个DataTable的数据或者复制另一个DataTabe中的数据 ...

  6. linux学习笔记--vi与vim编辑器

    vi编辑器全名为Visual Interface,即为可视化接口,类似于Windows中的记事本 vim相当于是vi的一个升级版本,包含vi的一切操作命令,vim相对于vi做了哪些提升: 1.vim支 ...

  7. Shell编程菜鸟基础入门笔记

    Shell编程基础入门     1.shell格式:例 shell脚本开发习惯 1.指定解释器 #!/bin/bash 2.脚本开头加版权等信息如:#DATE:时间,#author(作者)#mail: ...

  8. 【python】python定时器

    #coding:utf-8 import os import time def print_ts(message): print "[%s] %s"%(time.strftime( ...

  9. IAR快捷键:

    一显示行号:tools >> options >> Editor >> 选中show line numbers 2.注释的快捷键:Ctrl+K;取消注释:Ctrl+ ...

  10. mybatis动态调用表名和字段名

    以后慢慢启用个人博客:http://www.yuanrengu.com/index.php/mybatis1021.html 一直在使用Mybatis这个ORM框架,都是使用mybatis里的一些常用 ...