Monday , November 29 2021

Firebase Cloud Messaging for Android using PHP and MySQL – Android Coding by DMTechnolab

The package The trap.Simplified coding.Firebascloudmasing;

/ **

* Created by Belal on 03/11/16.

* /

Import Android.App.Notification;

Import Android.App.Notification manager;

Import Android.App.Pending;

Import Android.Content.Context;

Import Android.Content.Intent;

Import Android.The graphics.Bitmap;

Import Android.The graphics.Bitmap creation;

Import Android.Support.v4.App.Notification;

Import Android.The text.Html;

Import Java.I am.IOException;

Import Java.I am.input stream;

Import Java.The trap.HttpURLConnection;

Import Java.The trap.URL;

/ **

* Created by Ravi on 31/03/15.

* /

public class MyNotificationManager {{

public Fixed The last int ID_BIG_NOTIFICATION = 234;

public Fixed The last int ID_SMALL_NOTIFICATION = 235 is;

Private Context mCtx;

public MyNotificationManager()Context mCtx) {{

this.mCtx = mCtx;

}

// method will show a large notification with an image

// Parameters are message title, message to message text, URL of large image and an intent that will open

// when you tap on the notification

public Zero showBigNotification()String Title, String message, String url, Intent is intended) {{

Pending resultPendingIntent =

Pending.getActivity()

mCtx,

ID_BIG_NOTIFICATION,

is intended,

Pending.FLAG_UPDATE_Present

);

Notification.BigPictureStyle bigPictureStyle = New Notification.BigPictureStyle());

bigPictureStyle.setBigContentTitle()Title);

bigPictureStyle.setSummaryText()Html.From html()message).Wire()));

bigPictureStyle.big picture()getBitmapFromURL()url));

Notification.Builder mBuilder = New Notification.Builder()mCtx);

Notification Notification;

Notification = mBuilder.setSmallIcon()R.Mipmap.ic_launcher).Setticker()Title).When set()0)

.setAutoCancel()True)

.setContentIntent()resultPendingIntent)

.setContentTitle()Title)

.set of()bigPictureStyle)

.setSmallIcon()R.Mipmap.ic_launcher)

.setLargeIcon()Bitmap creation.decodeResource()mCtx.getResources()), R.Mipmap.ic_launcher))

.setContentText()message)

.Construction());

Notification.The flag | = Notification.FLAG_AUTO_CANCEL;

Notification manager informer = ()Notification manager) mCtx.getSystemService()Context.NOTIFICATION_SERVICE);

informer.please inform()ID_BIG_NOTIFICATION, Notification);

}

// method will show a short notification

// Parameter message title, message to message text and an intent that will open

// when you tap on the notification

public Zero showSmallNotification()String Title, String message, Intent is intended) {{

Pending resultPendingIntent =

Pending.getActivity()

mCtx,

ID_SMALL_NOTIFICATION,

is intended,

Pending.FLAG_UPDATE_Present

);

Notification.Builder mBuilder = New Notification.Builder()mCtx);

Notification Notification;

Notification = mBuilder.setSmallIcon()R.Mipmap.ic_launcher).Setticker()Title).When set()0)

.setAutoCancel()True)

.setContentIntent()resultPendingIntent)

.setContentTitle()Title)

.setSmallIcon()R.Mipmap.ic_launcher)

.setLargeIcon()Bitmap creation.decodeResource()mCtx.getResources()), R.Mipmap.ic_launcher))

.setContentText()message)

.Construction());

Notification.The flag | = Notification.FLAG_AUTO_CANCEL;

Notification manager informer = ()Notification manager) mCtx.getSystemService()Context.NOTIFICATION_SERVICE);

informer.please inform()ID_SMALL_NOTIFICATION, Notification);

}

// method will return bitmap from an image URL

Private Bitmap getBitmapFromURL()String Airs) {{

try {{

URL url = New URL()Airs);

HttpURLConnection The connection = ()HttpURLConnection) url.Openness());

The connection.setDoInput()True);

The connection.connect());

input stream Input = The connection.getInputStream());

Bitmap myBitmap = Bitmap creation.Decodestream()Input);

The return myBitmap;

} Hold ()IOException I) {{

I.Printstacktress());

The return Invalid;

}

}

}


Source link

About dmtechnolab

Check Also

Simplified Coding

Android Espresso Tutorial – Testing Fragment in Isolation – Android Coding by DMTechnolab

Welcome to another tutorial in the Android test series. And this post is called Android …

Leave a Reply

Your email address will not be published. Required fields are marked *