Idioma

Connection.OnShowIncomingCallUi Método

Definição

Notifica isso Connection de que ConnectionService ele é responsável por exibir sua interface de usuário de chamada de entrada para o Connection.

[Android.Runtime.Register("onShowIncomingCallUi", "()V", "GetOnShowIncomingCallUiHandler", ApiSince=26)]
public virtual void OnShowIncomingCallUi();
[<Android.Runtime.Register("onShowIncomingCallUi", "()V", "GetOnShowIncomingCallUiHandler", ApiSince=26)>]
abstract member OnShowIncomingCallUi : unit -> unit
override this.OnShowIncomingCallUi : unit -> unit
Atributos

Comentários

Notifica isso Connection de que ConnectionService ele é responsável por exibir sua interface de usuário de chamada de entrada para o Connection.

Será chamado apenas para chamadas de entrada adicionadas por meio de um autogerenciado ConnectionService (veja PhoneAccount#CAPABILITY_SELF_MANAGED), em que o ConnectionService usuário deve mostrar sua própria interface de usuário de chamada de entrada.

Quando há chamadas em andamento em outras chamadas autogerenciadas ConnectionServiceou regulares ConnectionService, e não é possível realizar essas outras chamadas, a estrutura de Telecomunicações exibirá sua própria interface de usuário de chamada de entrada para permitir que o usuário escolha se deseja atender à nova chamada de entrada e desconectar outras chamadas em andamento ou rejeitar a nova chamada de entrada.

Você deve disparar a exibição da interface do usuário de chamada de entrada para seu aplicativo mostrando um Notification com uma tela Intent inteira especificada.

No código do aplicativo, você deve criar uma android.app.NotificationChannel para notificações de chamada de entrada do seu aplicativo:

<code>
            NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
                     NotificationManager.IMPORTANCE_MAX);
            // other channel setup stuff goes here.

            // We'll use the default system ringtone for our incoming call notification channel.  You can
            // use your own audio resource here.
            Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
            channel.setSound(ringtoneUri, new AudioAttributes.Builder()
                     // Setting the AudioAttributes is important as it identifies the purpose of your
                     // notification sound.
                     .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
                     .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
                 .build());

            NotificationManager mgr = getSystemService(NotificationManager.class);
            mgr.createNotificationChannel(channel);
</code>

Quando chegar a hora de postar uma notificação para sua chamada de entrada, verifique se ela usa sua chamada android.app.NotificationChannelde entrada.

<code>
                // Create an intent which triggers your fullscreen incoming call user interface.
                Intent intent = new Intent(Intent.ACTION_MAIN, null);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.setClass(context, YourIncomingCallActivity.class);
                PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED);

                // Build the notification as an ongoing high priority item; this ensures it will show as
                // a heads up notification which slides down over top of the current content.
                final Notification.Builder builder = new Notification.Builder(context);
                builder.setOngoing(true);
                builder.setPriority(Notification.PRIORITY_HIGH);

                // Set notification content intent to take user to fullscreen UI if user taps on the
                // notification body.
                builder.setContentIntent(pendingIntent);
                // Set full screen intent to trigger display of the fullscreen UI when the notification
                // manager deems it appropriate.
                builder.setFullScreenIntent(pendingIntent, true);

                // Setup notification content.
                builder.setSmallIcon( yourIconResourceId );
                builder.setContentTitle("Your notification title");
                builder.setContentText("Your notification content.");

                // Set notification as insistent to cause your ringtone to loop.
                Notification notification = builder.build();
                notification.flags |= Notification.FLAG_INSISTENT;

                // Use builder.addAction(..) to add buttons to answer or reject the call.
                NotificationManager notificationManager = mContext.getSystemService(
                    NotificationManager.class);
                notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification);
</code>

Java documentação para android.telecom.Connection.onShowIncomingCallUi().

Partes desta página são modificações baseadas no trabalho criado e compartilhado pelo Project Open Source do Open Source e usadas de acordo com os termos descritos na Creative Commons 2.5.

Aplica-se a