Carlos D Trejo Carlos D Trejo - 1 year ago 41
Android Question

How can I send android push notifications through a QR Code?

I am developing an android application and using Zxing QR Code generator. I am wondering if the result of a QR Code can be an android push notification. If so, how can that be done? Thanks.

Answer Source

What you are looking for is to do a local notification as soon as a QR code is scanned and show the content of the scan result as a notification. Push notifications on the other hand are sent from server. Hence both are different

You can do Local notifications using NotificationCompat.Builder

A simple way to generate a notification is -

NotificationCompat.Builder mBuilder =
    new NotificationCompat.Builder(this)
    .setSmallIcon(R.drawable.notification_icon)
    .setContentTitle("My notification")
    .setContentText("Hello World!");

// Sets an ID for the notification
int mNotificationId = 001;
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr =
        (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(mNotificationId, mBuilder.build());

You can also learn about generating different types of notifications from the links below -

Link 1

Link 2

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download