简体   繁体   中英

Android push notification device to device

I want to make push notification without using GCM for device to device.I want to send information to any device using contact number.I also tried to look for it but couldn't find. I might be wrong but I must want to send push notification device device without using Google Cloud Messaging and as an when receive the notification on another device and open the notification , it should be open in an Activity.Can someone help me please.Thanks to appreciate.

To realize this app I think you should not confuse Android Notification with GCM push Notification. What you see in the android status bar are Android notification and you can show it using the Notification Builder class:

 Notification noti = new Notification.Builder(mContext)
         .setContentTitle("New mail from " + sender.toString())
         .setContentText(subject)
         .setSmallIcon(R.drawable.new_mail)
         .setLargeIcon(aBitmap)
         .build();

So I think you can send a text message using Android api as example from the web:

SmsManager smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(phoneNo, null, sms, null, null);
            Toast.makeText(getApplicationContext(), "SMS Sent!",
                        Toast.LENGTH_LONG).show();

And you do not need to use GCM push notification

to open the an activity from notification you can use:

NotificationManager notifManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notif = new Notification(icon, mess, when);

Intent notifIntent = new Intent(context, Activity.class);

notifIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
        | Intent.FLAG_ACTIVITY_SINGLE_TOP);

PendingIntent intent = PendingIntent.getActivity(context, 0, notifIntent, 0);

notif.setLatestEventInfo(context, title, mess, intent);
notif.flags |= Notification.FLAG_AUTO_CANCEL;
notifManager.notify(0, notif);

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