شروع فعالیت عینک روی نمایشگر عینک‌های هوش مصنوعی از طریق اعلان

دستگاه‌های XR قابل اجرا
این راهنما به شما کمک می‌کند تا برای این نوع دستگاه‌های XR تجربه ایجاد کنید.
عینک هوش مصنوعی

شما می‌توانید یک PendingIntent متفاوت را مشخص کنید که هنگام لمس یک اعلان روی صفحه نمایش عینک، فراخوانی می‌شود. این PendingIntent با intent پیش‌فرض تنظیم‌شده برای تلفن با استفاده از setContentIntent متفاوت است. برای مثال، وقتی کاربر روی اعلان روی صفحه نمایش عینک هوش مصنوعی ضربه می‌زند، یک activity خاص عینک روی صفحه نمایش عینک هوش مصنوعی اجرا می‌شود.

برای افزودن رفتارهای خاص عینک، از ProjectedExtender استفاده کنید. این API به شما امکان می‌دهد رفتار اعلان‌ها را روی عینک سفارشی کنید، بدون اینکه روی نحوه نمایش آنها روی گوشی تأثیر بگذارد.

کاتلین

// 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());