/**

  //开机之后打开服务  开机成功打开服务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. ABBYY FineReader 12对系统有哪些要求

    ABBYY FineReader是市场领先的ocr文字识别软件,可快速方便地将扫描的文档.PDF文档和图像文件(包括数码照片)转化为可编辑.可搜索的格式.每个软件都有其安装运行的系统要求,ABBYY ...

  2. 学习地址(oraclemysqllinux)

    1.安装配置 http://blog.chinaunix.net/uid-27126319-id-3466193.htmlhttp://www.cnblogs.com/gaojun/archive/2 ...

  3. Javascript模式(第三章字面量与构造函数)------读书笔记

    一 对象字面量 1.1对象字面量的语法 1,对象键值对哈希表,在其他的编程语言中称之为“关联数组”, 2 键值对里面的值,可以是原始类型也可以是其他类型的对象,称之为属性,函数称之为方法 3 自定义对 ...

  4. MyBatis学习(三)、动态SQL语句

    三.动态SQL语句 有些时候,sql语句where条件中,需要一些安全判断,例如按某一条件查询时如果传入的参数是空,此时查询出的结果很可能是空的,也许我们需要参数为空时,是查出全部的信息.使用Orac ...

  5. HTML input-file 上传类型控制

    HTML input-file 上传类型控制 input file 属性 accept 表示可以选择的文件MIME类型,多个MIME类型用英文逗号分开,常用的MIME类型见下表. 只能选择png和gi ...

  6. java动态绑定的一点注意

    动态绑定只是针对对象的方法,对于属性无效.因为属性不能被重写. show me code: public class Father{ public String name = "父亲属性&q ...

  7. Netty的TCP粘包/拆包(源码二)

    假设客户端分别发送了两个数据包D1和D2给服务器,由于服务器端一次读取到的字节数是不确定的,所以可能发生四种情况: 1.服务端分两次读取到了两个独立的数据包,分别是D1和D2,没有粘包和拆包. 2.服 ...

  8. Android 对话框(Dialog)大全 建立你自己的对话框

    Android 对话框(Dialog)大全 建立你自己的对话框 原文地址: http://www.cnblogs.com/salam/archive/2010/11/15/1877512.html A ...

  9. 让一个端口同时做两件事:http/https和ssh

    相信很多人都在YY:能不能让80端口分析连接协议,如果是http协议就让服务器交给http服务程序(如Apache.Nginx等)处理,如果是ssh协议就交给ssh服务程序(如OpenSSH Serv ...

  10. ./upload/forum.php

    这是forum.php的全部代码,然后试着读一读,自己做做笔记. define('APPTYPEID', 2); define('CURSCRIPT', 'forum'); define(); 定义常 ...