关于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前拍了这么一段.但是呢,有很多的不理想: 画面抖动 杂音好烦(中午吃饭时拍的,还有好大的微波炉好了的声音 ...
随机推荐
- Python 面向对象2
静态方法 静态方法相当于函数,可以不创建对象直接引用 如果在类里面用静态方法,相当于函数,可以不创建对象,直接是用类里面的方法,你就当它是函数. 静态方法名义上归类管理,实际上静态方法访问不了类或实例 ...
- 解决Shiro注解无效的问题
当Shiro集成到Spring mvc中,却发现shiro的权限注解不起作用,官方的配置是要支持注解,只需要将以下代码加到spring 配置文件中即可: <bean class="or ...
- NetApp常用检查命令
常用检查命令 ************************************* ******************************************************* ...
- dubbo服务自动化测试搭建
java实现dubbo的消费者服务编写:ruby实现消费者服务的接口测试:通过消费者间接测试dubbo服务接口的逻辑 内容包括:dubbo服务本地调用环境搭建,dubbo服务启动,消费者部署,脚本编写 ...
- javascript 数组去重 unique
晚上无事,偶然看到这么个小测试,拿来写一写,希望大家提建议: 直接上代码: Array.prototype.unique = function (isStrict) { if (this.length ...
- git学习1:git安装和配置
Git是什么?世界上最先进的分布式版本控制系统,记录了一个文本文件的每次一修改信息,比如,一篇散文,从草稿到最终出版,经历过无数次修改,修改了标点符号形成一个版本,老师帮助修改形成一个版本,同学帮忙修 ...
- Spark 1.6以后的内存管理机制
Spark 内部管理机制 Spark的内存管理自从1.6开始改变.老的内存管理实现自自staticMemoryManager类,然而现在它被称之为"legacy". " ...
- SQL优化注意事项
sql语句优化 性能不理想的系统中除了一部分是因为应用程序的负载确实超过了服务器的实际处理能力外,更多的是因为系统存在大量的SQL语句需要优化. 为了获得稳定的执行性能,SQL语句越简单越好.对复杂的 ...
- dos笔记
MS DOS 命令大全 一.基础命令 1 dir 无参数:查看当前所在目录的文件和文件夹. /s:查看当前目录已经其所有子目录的文件和文件夹. /a:查看包括隐含文件的所有文件. /ah:只显示出隐含 ...
- “XXX::Invoke”类型的已垃圾回收委托进行了回调。这可能会导致应用程序崩溃、损坏和数据丢失。向非托管代码传递委托时,托管应用程序必须让这些委托保持活动状态,直到确信不会再次调用它们。
症状描述如下: 如果将一个委托作为函数指针从托管代码封送到非托管代码,并且在对该委托进行垃圾回收后对该函数指针发出了一个回调,则将激活 callbackOnCollectedDelegate 托管调试 ...