Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android推送通知设备到设备_Java_Android_Push Notification - Fatal编程技术网

Java Android推送通知设备到设备

Java Android推送通知设备到设备,java,android,push-notification,Java,Android,Push Notification,我想在不使用GCM的情况下为设备到设备发送推送通知。我想使用联系人号码向任何设备发送信息。我也尝试过查找,但找不到。我可能错了,但我必须要发送推送通知设备而不使用谷歌云消息,并且当在另一台设备上收到通知并打开通知时,它应该在活动中打开。请有人帮助我。谢谢 要实现这个应用程序,我认为你不应该混淆Android通知和GCM推送通知。您在android状态栏中看到的是android通知,您可以使用notification Builder类显示它: Notification noti = new No

我想在不使用GCM的情况下为设备到设备发送推送通知。我想使用联系人号码向任何设备发送信息。我也尝试过查找,但找不到。我可能错了,但我必须要发送推送通知设备而不使用谷歌云消息,并且当在另一台设备上收到通知并打开通知时,它应该在活动中打开。请有人帮助我。谢谢

要实现这个应用程序,我认为你不应该混淆Android通知和GCM推送通知。您在android状态栏中看到的是android通知,您可以使用notification Builder类显示它:

 Notification noti = new Notification.Builder(mContext)
         .setContentTitle("New mail from " + sender.toString())
         .setContentText(subject)
         .setSmallIcon(R.drawable.new_mail)
         .setLargeIcon(aBitmap)
         .build();
因此,我认为您可以使用Android api从web发送一条文本消息:

SmsManager smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(phoneNo, null, sms, null, null);
            Toast.makeText(getApplicationContext(), "SMS Sent!",
                        Toast.LENGTH_LONG).show();
而且您不需要使用GCM推送通知

要从通知打开“活动”,您可以使用:

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);

什么是联系电话?你是说电话号码吗?@aorlando:-是的,因为在我的应用程序中,用户只需输入姓名、产品和他的联系电话,我就可以通过联系电话在他的设备上发送通知。:-谢谢你的回复,但我最大的问题是当用户收到通知时,我想在活动中打开。我不能在这里发布一个完整的sampl,但网络上充满了这种东西::-我尝试过examples.javacodegeeks.com/android/core/ui/notifications/这个例子,但通知不会发送到另一个设备。甚至我也更改了线路of//创建一个隐式的intent 112 intent resultint=new intent(“com.example.javacodegeeks.TEL_intent”,113 Uri.parse(“TEL:123456789”);114 resultent.putExtra(“来自”,“javacodegeeks”);