因此,我们已经找到了解决方案(当收到通知时,将应用程序置于前台),即使已经有一段时间了,我仍在发布它:

> 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视频通话,唤醒应用程序并进入前台相关推荐

  1. 信android开发视频教程,android 视频通话 实例源码(网易云信sdk)

    [实例简介] [实例截图] [核心代码] package com.netease.nim.demo.chatroom.activity; import android.content.Context; ...

  2. 视频教程-Android WebRTC 实现1V1实时音视频通信-Android

    Android WebRTC 实现1V1实时音视频通信 从2012年开始从事移动互联网方面的开发工作,曾担任去哪儿网开发工程师,搜狗高级开发工程师,拥有多年一线实战开发经验. 擅长语言:Object- ...

  3. Android/linux(earlysuspend、lateresume)睡眠唤醒机制简

    来源处 http://blog.sina.com.cn/s/blog_759dc36b0100stax.html 背景介绍: 睡眠/唤醒是嵌入式Linux非常重要的组成部分,因为优秀的睡眠唤醒机制可以 ...

  4. 老罗Android开发视频教程( android解析json数据 )4集集合

    老罗Android开发视频教程( android解析json数据 )4集集合 老罗Android开发视频教程( android解析json数据 ) 第一集android解析json数据 http:// ...

  5. Mars《Android开发视频教程》全集下载(第一季到第五季)

    转发地址:http://blog.sina.com.cn/s/blog_4a5c3f450102uyti.html Mars<Android开发视频教程>第一季 [百度网盘]http:// ...

  6. 老罗android开发视频教程 下载地址

    感觉老罗android开发视频教程讲得挺好挺全面的,适合新手学习.分享 老罗android开发视频教程 下载地址: 电驴:http://www.verycd.com/topics/2929580/ 老 ...

  7. 视频教程-仿淘宝客户端电商平台android初级速成-Android

    仿淘宝客户端电商平台android初级速成 北风网技术总监,在某大型电信设备公司担任架构师,主要从事电信领域的软件开发,经验丰富.对电信计费系统以及核心网软件系统有深入了解,对设计高可靠性,高扩展性的 ...

  8. 【Android 电量优化】电量优化 ( 唤醒锁定 | 使用 WeakLock 保持服务唤醒 | 屏幕唤醒 )

    文章目录 一.使用 WeakLock 保持 CPU 唤醒 ( 费电操作 ) 1.保持 CPU 唤醒 2.使用 WeakLock 保持 CPU 唤醒流程 3.使用 WeakLock 保持 CPU 唤醒代 ...

  9. 直播软件源码如何在Android端实现多人视频通话

    本篇主要讨论直播软件源码如何在Android端实现多人视频通话.主要需要实现以下功能: 随着加入人数和他们的手机摄像头分辨率的变化,显示不同的UI,即所谓的"分屏" 点击分屏中的小 ...

最新文章

  1. 数组--存储地址的计算
  2. 腾讯广告广点通API接入文档(Android)
  3. 2018-3-21李宏毅机器学习视频笔记(十三)--“Hello Wrold” of Deep learning
  4. 启动tomcat提示Could not create the Java virtual machine.
  5. 最小生成树实验报告c语言,最小生成树(C语言, prim算法)
  6. 第二届大数据科学与工程国际会议在贵阳成功召开
  7. 数据结构期末复习(に)--链式栈定义及使用
  8. 格力手机没有放弃!将跟上5G和柔性屏的大势
  9. 中风偏瘫疾病的预防方法是什么
  10. Google将推中文信息流产品,今日头条们请注意~
  11. suse linux11下的多网口位置确定
  12. nandflash移植程序_韦东山鸿蒙移植01-移植RTOS需要做的事
  13. 【转】android 完全退出应用程序
  14. 硬核讲习,10名“悟道”核心成员,剖析大模型
  15. 《大数据大创新:阿里巴巴云上数据中台之道》:解密阿里数据中台建设
  16. Django(十二)模型表关系的实现
  17. 群论基础速成(6):五大著名群族
  18. 挖掘长尾关键词的五大思路
  19. 属性级情感分析(于restaurant14和laptop14数据集上使用LSTM和GRU、 MemNet和IAN以及CNN等)的对比分析
  20. Selenium基础知识 多窗口处理

热门文章

  1. 星期五基准功能Java
  2. 具有Java 8支持的Spring Framework 4.0.3和Spring Data Redis 1.2.1
  3. 在JDT中使用Java 8 Lambda
  4. Java Collections API怪癖
  5. Java 7:HashMap与ConcurrentHashMap
  6. REST + Spring Security会话问题
  7. NetBeans可用性提示
  8. 将Ehcache添加到Openxava应用程序
  9. Linux 命令之 lsusb -- 显示本机的USB设备列表信息
  10. phpexcel 日期 时分秒_thinkPHP+PHPExcel实现读取文件日期的方法含时分秒