0
私のデバイスで通知を受け取ったときに通知を最小化すると、最小化されたアプリケーションのリストから消えてしまうため、通知バック。ここで 通知を最小化したときに通知が失われる
は//GcmNotificationRedirect
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pushRedirect();
}
private void pushRedirect()
{
pushMessage = getIntent().getStringExtra("pushMessage");
bundleData = getIntent().getStringExtra("bundleData");
parsePushNotifiactionJson(pushMessage,bundleData);
finish();
}
private void parsePushNotifiactionJson(String pushMessage, String bundleJSONData){
Intent pushNotiInetent = null;
if(pushMessage!=null && bundleJSONData!=null) {
try {
JSONObject jsonObject = new JSONObject(bundleJSONData);
if (jsonObject.getString("type").equals(PRODUCT_PAGE)) {
pojo = new Push_Notification_Pojo(jsonObject.getString("productId"), jsonObject.getString("type"),pushMessage);
pushNotiInetent = new Intent(this, ProductDetail.class);
pushNotiInetent.putExtra("push_notification_pojo", pojo);
startActivity(pushNotiInetent);
}
else
{
pojo = new Push_Notification_Pojo(jsonObject.getString("promotionId"), jsonObject.getString("type"), pushMessage, true);
if(pojo!=null)
{
pushNotiInetent = new Intent(this,PushNotificationPromotion.class);
pushNotiInetent.putExtra("pushMessage", pushMessage);
pushNotiInetent.putExtra("bundleData",bundleData);
startActivity(pushNotiInetent);
}
}
Log.d("Push",pojo.getType()+" "+pojo.getProductId()+" "+pojo.getPromotionId());
}
catch (JSONException e) {
e.printStackTrace();
}
}
}
}
すべてが正常に動作している。これは、適切なアクティビティにデータを渡す活動がある
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setNotification(String message,String bundledata)
{
NotificationManager mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(this, GcmNotificationRedirect.class);
notificationIntent.putExtra("pushMessage", message);
notificationIntent.putExtra("bundleData",bundledata);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(this, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setContentTitle(title)
.setPriority(Notification.PRIORITY_MAX)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(message))
.setContentText(message)
.setNumber(pushNumber);
mBuilder.setColor(this.getResources().getColor(R.color.theme_color));
mBuilder.setSmallIcon(R.drawable.app_icon);
mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), getNotificationIcon()));
mBuilder.setContentIntent(resultPendingIntent);
mBuilder.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
Notification notification = mBuilder.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
messegeハンドラサービスのコードですが、私は取得することができません私がそれを最小限にした時の通知を返します..