বাংলায় অ্যান্ড্রয়েড সহায়িকা - Bangla Android Guide

একটি নতুন একটিভিটি শুরু করার জন্য নোটিফিকেশন সেট আপ করা

নমুনা অ্যাপলিকেশন নোটিফিকেশন তৈরী এবং ইস্যু করতে একটি IntentSerrvice সাবক্লাস (PingService) ব্যবহার করে।

এই কোড চিত্রটির মধ্যে, IntentService পদ্ধতি onHandleIntent()একটি নতুন একটিভিটি নির্দিষ্ট করে যা শুরু হবে যদি ইউজার নোটিফিকেশনটিকেই ক্লিক করে। পদ্ধতি setContentIntent() একটি মূলতবী রাখা ইনটেন্ট নির্ধারণ করে যার ফায়ারড হওয়া উচিত যখন ইউজার নোটিফিকেশন ক্লিক করে, এই উপায়ে একটিভিটি শুরু করে।

Intent resultIntent = new Intent(this, ResultActivity.class);
resultIntent.putExtra(CommonConstants.EXTRA_MESSAGE, msg);
resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
        Intent.FLAG_ACTIVITY_CLEAR_TASK);

// Because clicking the notification launches a new ("special") activity,
// there's no need to create an artificial back stack.
PendingIntent resultPendingIntent =
         PendingIntent.getActivity(
         this,
         0,
         resultIntent,
         PendingIntent.FLAG_UPDATE_CURRENT
);

// This sets the pending intent that should be fired when the user clicks the
// notification. Clicking the notification launches a new activity.
builder.setContentIntent(resultPendingIntent);