要实现这个应用程序,我认为您不应该将 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 作为网络示例发送短信:
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);