![](/img/trans.png)
[英]Android Parse Push Notification not working - “Outdated device”
[英]Android push notification device to device
我想在不使用GCM將設備發送到設備的情況下發出推送通知。我想使用聯系電話將信息發送到任何設備。我也試圖尋找它,但找不到。 我可能是錯的,但我必須要在不使用Google Cloud Messaging的情況下發送推送通知設備的設備,並且當在另一台設備上收到通知並打開通知時,它應該在``活動''中打開。有人可以幫幫我嗎。謝謝欣賞。
為實現此應用程序,我認為您不應將Android Notification與GCM push Notification混淆。 您在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作為示例發送短信:
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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.