Langue

Connection.OnShowIncomingCallUi Méthode

Définition

Avertit cela Connection qu’il ConnectionService est responsable de l’affichage de son interface utilisateur d’appel entrante pour le 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
Attributs

Remarques

Avertit cela Connection qu’il ConnectionService est responsable de l’affichage de son interface utilisateur d’appel entrante pour le Connection.

Sera uniquement appelé pour les appels entrants ajoutés via un auto-géré ConnectionService (voir PhoneAccount#CAPABILITY_SELF_MANAGED), où le ConnectionService doit afficher son propre interface utilisateur d’appel entrante.

Lorsqu’il existe des appels en cours dans d’autres appels autogérés ConnectionServiceou dans un système normal ConnectionService, et qu’il n’est pas possible de contenir ces autres appels, l’infrastructure Telecom affiche son propre interface utilisateur d’appel entrant pour permettre à l’utilisateur de choisir de répondre au nouvel appel entrant et de déconnecter d’autres appels en cours, ou de rejeter le nouvel appel entrant.

Vous devez déclencher l’affichage de l’interface utilisateur d’appel entrante pour votre application en affichant un Notification écran Intent complet spécifié.

Dans votre code d’application, vous devez créer un android.app.NotificationChannel pour les notifications d’appel entrantes à partir de votre application :

<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>

Quand il est temps de publier une notification pour votre appel entrant, assurez-vous qu’il utilise votre appel android.app.NotificationChannelentrant .

<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 documentation pour android.telecom.Connection.onShowIncomingCallUi().

Les parties de cette page sont des modifications basées sur le travail créé et partagé par Android Open Source et utilisées en fonction des termes décrits dans la Creative Commons 2.5 Attribution License.

S’applique à