android前台进程视频教程,Android Twilio视频通话,唤醒应用程序并进入前台
因此,我们已经找到了解决方案(当收到通知时,将应用程序置于前台),即使已经有一段时间了,我仍在发布它:
> FCM通知(firebase云消息传递通知)只需在通知中发送“数据”.因此,通知的JSON结构中没有Notification对象,只有数据.这样,通知便由您应用的FirebaseMessagingService.java类处理.请详细阅读以下内容,以了解如何处理两种FCM通知类型.
https://firebase.google.com/docs/cloud-messaging/android/receive
https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
>在FirebaseMessagingService.java类中,使用Intent启动VideoCall活动.不要忘记将此服务添加到Manifest.xml中
Intent intent = new Intent(this, VideoCallActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
getApplicationContext().startActivity(intent);
>在VideoCall活动中,确保在onCreate()的开头具有以下代码:
// These flags ensure that the activity can be launched when the screen is locked.
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// to wake up screen
PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
wakeLock.acquire();
// to release screen lock
KeyguardManager keyguardManager = (KeyguardManager) getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("TAG");
keyguardLock.disableKeyguard();
>使用相应的intent-filter将VideoCallActivity添加到Manifest.xml中:
????android:name =“.ui.activities.video_call.VideoCallActivity”
????android:launchMode =“ singleTop”
????android:screenOrientation =“ portrait”
????android:theme =“ @ style / AppTheme.NoActionBar”>
????
????????
????????< action android:name =“ VIDEO_CALLING” />
????????< category android:name =“ android.intent.category.DEFAULT” />
????< / intent-filter>
< / activity>
可选的:
要使电话响起并振动:
// For Incoming Call
// 1. declare
private MediaPlayer incomingCallMediaPlayer;
// .2 in onCreate, if I'm the person that's calling, ring the phone
incomingCallMediaPlayer = MediaPlayer.create(this, R.raw.incoming);
incomingCallMediaPlayer.setLooping(true);
incomingCallMediaPlayer.start();
// 3. when I pick up, stop the player
incomingCallMediaPlayer.stop();
// I play R.raw.incoming if I'm being called.
// I play R.raw.outgoing when I'm calling.
// I understand if I'm the one calling from the number of participants in the "room" (this is a video call terminology) and by passing in a variable through the intent
// For Outgoing Call
// 1. declare
private MediaPlayer callingMediaPlayer;
// 2. in onCreate, if I'm being called, ring the phone
callingMediaPlayer = MediaPlayer.create(this, R.raw.outgoing);
callingMediaPlayer.setLooping(true);
callingMediaPlayer.start();
// 3. when another "participant" (this is a video call terminology) joins the "room" I stop playing the sound
callingMediaPlayer.stop();
// to Vibrate, add the code with the media players and stop vibrate with media players
//https://stackoverflow.com/questions/13950338/how-to-make-an-android-device-vibrate
android前台进程视频教程,Android Twilio视频通话,唤醒应用程序并进入前台相关推荐
- 信android开发视频教程,android 视频通话 实例源码(网易云信sdk)
[实例简介] [实例截图] [核心代码] package com.netease.nim.demo.chatroom.activity; import android.content.Context; ...
- 视频教程-Android WebRTC 实现1V1实时音视频通信-Android
Android WebRTC 实现1V1实时音视频通信 从2012年开始从事移动互联网方面的开发工作,曾担任去哪儿网开发工程师,搜狗高级开发工程师,拥有多年一线实战开发经验. 擅长语言:Object- ...
- Android/linux(earlysuspend、lateresume)睡眠唤醒机制简
来源处 http://blog.sina.com.cn/s/blog_759dc36b0100stax.html 背景介绍: 睡眠/唤醒是嵌入式Linux非常重要的组成部分,因为优秀的睡眠唤醒机制可以 ...
- 老罗Android开发视频教程( android解析json数据 )4集集合
老罗Android开发视频教程( android解析json数据 )4集集合 老罗Android开发视频教程( android解析json数据 ) 第一集android解析json数据 http:// ...
- Mars《Android开发视频教程》全集下载(第一季到第五季)
转发地址:http://blog.sina.com.cn/s/blog_4a5c3f450102uyti.html Mars<Android开发视频教程>第一季 [百度网盘]http:// ...
- 老罗android开发视频教程 下载地址
感觉老罗android开发视频教程讲得挺好挺全面的,适合新手学习.分享 老罗android开发视频教程 下载地址: 电驴:http://www.verycd.com/topics/2929580/ 老 ...
- 视频教程-仿淘宝客户端电商平台android初级速成-Android
仿淘宝客户端电商平台android初级速成 北风网技术总监,在某大型电信设备公司担任架构师,主要从事电信领域的软件开发,经验丰富.对电信计费系统以及核心网软件系统有深入了解,对设计高可靠性,高扩展性的 ...
- 【Android 电量优化】电量优化 ( 唤醒锁定 | 使用 WeakLock 保持服务唤醒 | 屏幕唤醒 )
文章目录 一.使用 WeakLock 保持 CPU 唤醒 ( 费电操作 ) 1.保持 CPU 唤醒 2.使用 WeakLock 保持 CPU 唤醒流程 3.使用 WeakLock 保持 CPU 唤醒代 ...
- 直播软件源码如何在Android端实现多人视频通话
本篇主要讨论直播软件源码如何在Android端实现多人视频通话.主要需要实现以下功能: 随着加入人数和他们的手机摄像头分辨率的变化,显示不同的UI,即所谓的"分屏" 点击分屏中的小 ...
最新文章
- 数组--存储地址的计算
- 腾讯广告广点通API接入文档(Android)
- 2018-3-21李宏毅机器学习视频笔记(十三)--“Hello Wrold” of Deep learning
- 启动tomcat提示Could not create the Java virtual machine.
- 最小生成树实验报告c语言,最小生成树(C语言, prim算法)
- 第二届大数据科学与工程国际会议在贵阳成功召开
- 数据结构期末复习(に)--链式栈定义及使用
- 格力手机没有放弃!将跟上5G和柔性屏的大势
- 中风偏瘫疾病的预防方法是什么
- Google将推中文信息流产品,今日头条们请注意~
- suse linux11下的多网口位置确定
- nandflash移植程序_韦东山鸿蒙移植01-移植RTOS需要做的事
- 【转】android 完全退出应用程序
- 硬核讲习,10名“悟道”核心成员,剖析大模型
- 《大数据大创新:阿里巴巴云上数据中台之道》:解密阿里数据中台建设
- Django(十二)模型表关系的实现
- 群论基础速成(6):五大著名群族
- 挖掘长尾关键词的五大思路
- 属性级情感分析(于restaurant14和laptop14数据集上使用LSTM和GRU、 MemNet和IAN以及CNN等)的对比分析
- Selenium基础知识 多窗口处理
热门文章
- 星期五基准功能Java
- 具有Java 8支持的Spring Framework 4.0.3和Spring Data Redis 1.2.1
- 在JDT中使用Java 8 Lambda
- Java Collections API怪癖
- Java 7:HashMap与ConcurrentHashMap
- REST + Spring Security会话问题
- NetBeans可用性提示
- 将Ehcache添加到Openxava应用程序
- Linux 命令之 lsusb -- 显示本机的USB设备列表信息
- phpexcel 日期 时分秒_thinkPHP+PHPExcel实现读取文件日期的方法含时分秒