একটি বিজ্ঞপ্তি থেকে ডিসপ্লে AI চশমায় চশমার কার্যকলাপ শুরু করুন

প্রযোজ্য XR ডিভাইস
এই নির্দেশিকা আপনাকে এই ধরণের XR ডিভাইসের অভিজ্ঞতা তৈরি করতে সাহায্য করবে।
এআই চশমা

আপনি একটি ভিন্ন PendingIntent নির্দিষ্ট করতে পারেন যা চশমার ডিসপ্লেতে একটি বিজ্ঞপ্তি ট্যাপ করার সময় আহ্বান করা হয়। এই PendingIntent setContentIntent ব্যবহার করে ফোনের জন্য ডিফল্ট ইন্টেন্ট সেট থেকে আলাদা। উদাহরণস্বরূপ, যখন ব্যবহারকারী ডিসপ্লে AI চশমার বিজ্ঞপ্তিতে ট্যাপ করেন, তখন ডিসপ্লে AI চশমার উপর একটি নির্দিষ্ট চশমার কার্যকলাপ চালু হয়।

চশমা-নির্দিষ্ট আচরণ যোগ করতে, 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());