【问题标题】:Start activity or full screen intent from background in android从android中的背景启动活动或全屏意图
【发布时间】:2021-03-10 11:49:36
【问题描述】:

当有人打电话时,我必须从后台开始通话活动。我已经尝试过这段代码,但它不起作用。通知未到来且不存在错误。我犯了什么错误。

Intent fullScreenIntent = new Intent(conn, IncCallActivity.class);
fullScreenIntent.putExtra("name", callerName);
fullScreenIntent.putExtra("out", false);
fullScreenIntent.putExtra("channel_id", channelId);
fullScreenIntent.putExtra("id", callerId);

PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(conn, 112,fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT);

Uri sound = Uri.parse(((AppBack) getApplication()).shared().getString("ringU", "no"));

NotificationManager notificationManager =(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

NotificationChannel mChannel = notificationManager.getNotificationChannel("VIDEO_CALL");
                                                
AudioAttributes attributes = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
                                                        .setUsage(AudioAttributes.USAGE_ALARM)
                                                        .build();
if (mChannel == null) {
         mChannel = new NotificationChannel("VIDEO_CALL", "VIDEO_CALL",NotificationManager.IMPORTANCE_HIGH);
         mChannel.setSound(sound, attributes);
         notificationManager.createNotificationChannel(mChannel);
}

NotificationCompat.Builder builder = new NotificationCompat.Builder(conn, " VIDEO_CALL").setSmallIcon(R.drawable.logo)
                                                        .setContentTitle("Incoming call")
                                                        .setContentText("Call from " + callFrom)
                                                        .setPriority(NotificationCompat.PRIORITY_HIGH)
                                                        .setCategory(NotificationCompat.CATEGORY_CALL)
                                                        .setContentIntent(fullScreenPendingIntent)
                                                        .setFullScreenIntent(fullScreenPendingIntent, true)
                                                        .setAutoCancel(true)
                                                        .setOngoing(true);

Notification notification = builder.build();
notificationManager.notify(120, notification); 

【问题讨论】:

    标签: java android mobile-application


    【解决方案1】:

    我认为你应该给AndroidManifest.xml添加权限。

    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
    
    1. 设备应该被锁定

    【讨论】:

      猜你喜欢
      • 2013-04-14
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-12
      • 2023-03-16
      相关资源
      最近更新 更多