如何在Android手机中发送锁屏推送通知。我的代码是
mNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class), 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setSmallIcon(R.drawable.gcm_cloud)
.setContentTitle("Notification")
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg);
mBuilder.setContentIntent(contentIntent);
PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG"); wl.acquire(15000);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
答案 0 :(得分:0)
你不能,因为:
Push notifications
从系统发送到另一个系统。您只需要“常规”通知,这与GCM无关。android-4.4-kitkat
问题标签是一个线索。