알림에서 디스플레이 AI 글래스에서 글래스 활동 시작

적용 가능한 XR 기기
이 가이드에서는 이러한 유형의 XR 기기를 위한 환경을 빌드하는 방법을 설명합니다.
AI 안경

다른 PendingIntent를 지정할 수 있습니다. 이 알림은 글라스 디스플레이에서 탭할 때 호출됩니다. 이 PendingIntentsetContentIntent을 사용하여 휴대전화에 설정된 기본 인텐트와는 다릅니다. 예를 들어 사용자가 디스플레이 AI 안경의 알림을 탭하면 디스플레이 AI 안경에서 특정 안경 액티비티가 실행됩니다.

안경별 동작을 추가하려면 ProjectedExtender를 사용하세요. 이 API를 사용하면 휴대전화에 표시되는 방식에 영향을 주지 않고 안경의 알림 동작을 맞춤설정할 수 있습니다.

Kotlin

// Intent to fire when tapped on the phone
val phoneIntent = Intent(this, MyPhoneActivity::class.java)
val phonePendingIntent = PendingIntent.getActivity(
    this, 0, phoneIntent, PendingIntent.FLAG_IMMUTABLE
)

// Intent to fire when tapped on the glasses display
val glassesIntent = Intent(this, MyGlassesActivity::class.java)
val glassesPendingIntent = PendingIntent.getActivity(
    this, 1, glassesIntent, PendingIntent.FLAG_IMMUTABLE
)

// Create the base notification
val builder = NotificationCompat.Builder(this, CHANNEL_ID).apply {
    setSmallIcon(R.drawable.ic_notification)
    setContentTitle("Navigation in Progress")
    setContentText("Tap to see details")
    // Default intent for phone
    setContentIntent(phonePendingIntent)

    // Create and apply the glasses extender
    val projectedExtender = ProjectedExtender().setContentIntent(glassesPendingIntent)

    extend(projectedExtender)
}

// Issue the notification
notificationManager.notify(NOTIFICATION_ID, builder.build())

자바

// Intent to fire when tapped on the phone
Intent phoneIntent = new Intent(this, MyPhoneActivity.class);
PendingIntent phonePendingIntent =
    PendingIntent.getActivity(this, 0, phoneIntent, PendingIntent.FLAG_IMMUTABLE);

// Intent to fire when tapped on the glasses display
Intent glassesIntent = new Intent(this, MyGlassesActivity.class);
PendingIntent glassesPendingIntent =
    PendingIntent.getActivity(this, 1, glassesIntent, PendingIntent.FLAG_IMMUTABLE);

// Create the base notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
    .setSmallIcon(R.drawable.ic_notification)
    .setContentTitle("New Update")
    .setContentText("Something important happened.")
    // Default intent for phone
    .setContentIntent(phonePendingIntent);

// Create and apply the Glasses extender
ProjectedExtender projectedExtender = new ProjectedExtender()
    // glasses-specific intent
    .setContentIntent(glassesPendingIntent);
builder.extend(projectedExtender);

// Issue the notification
notificationManager.notify(NOTIFICATION_ID, builder.build());