日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android前台进程视频教程,Android Twilio视频通话,唤醒应用程序并进入前台

發布時間:2023/12/2 Android 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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视频通话,唤醒应用程序并进入前台的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。