简体   繁体   中英

How to use external large image in Android notification bar like Facebook or etc on firemonkey Delphi XE 8?

I know you can send info in the push notification parameters like message, title, image URL, etc. How does Facebook show your profile pic with your message in the notification area? I want to use an external image in the notification area, so when you pull it down you see the profile image with the message. Right now, mine just shows the default icon. I figured this might be a common question but couldn't find anything. Any help would be nice.

Please refer to the photo link.

https://goo.gl/photos/somTJPUYNnSWpTwV9

You can create custom notifications using whatever images you want. The code is this:

NotificationCompat.Builder mBuilder =
    new NotificationCompat.Builder(getApplicationContext())
            // The icon to be shown in the small view.
            .setSmallIcon(R.drawable.notification_icon_small)
            // The icon to be shown in the expanded view.
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon_large))
            // The sound to be played when notification is generated
            .setSound(RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION))
            // The title of the notification.
            .setContentTitle("Time's Up")
            // Message to be shown in expanded view.
            .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
            // The message to be shown in collapsed view.
            .setContentText("Stop using your phone now");

NotificationManager notificationManager =
    (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

// Show the notification using this.
notificationManager.notify(0, mBuilder.build());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM