This condition is for gcm notification get activity
public class GCMNotificationIntentService extends IntentService {
// Sets an ID for the notification, so it can be updated
public static final int notifyID = 9001;
NotificationCompat.Builder builder;
int count, i;
public GCMNotificationIntentService() {
super("GcmIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()) {
if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
.equals(messageType)) {
sendNotification("Send error: " + extras.toString());
} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
.equals(messageType)) {
sendNotification("Deleted messages on server: "
+ extras.toString());
} else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE
.equals(messageType)) {
sendNotification("Message Received from Google GCM Server:\n\n"
+ extras.get(ApplicationConstants.MSG_KEY));
}
}
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
private void sendNotification(String msg) {
Log.d("Notification-msssg", msg);
Log.d("Notification-msssg", msg);
if (msg.equals("Property")) {
Log.d("Notification-msssg", msg + "chat");
Log.d("Notification-msssgchat", msg);
Intent resultIntent = new Intent(this, MessageListActivity.class);
resultIntent.putExtra("msg", msg);
PendingIntent resultPendingIntent = PendingIntent.getActivity(this,
0, resultIntent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder mNotifyBuilder;
NotificationManager mNotificationManager;
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotifyBuilder = new NotificationCompat.Builder(this)
.setContentTitle("CPO")
.setContentText("You've received new message.")
.setSmallIcon(R.drawable.iconnotifi);
// Set pending intent
mNotifyBuilder.setContentIntent(resultPendingIntent);
// Set Vibrate, Sound and Light
int defaults = 0;
defaults = defaults | Notification.DEFAULT_LIGHTS;
defaults = defaults | Notification.DEFAULT_VIBRATE;
defaults = defaults | Notification.DEFAULT_SOUND;
mNotifyBuilder.setDefaults(defaults);
// Set the content for Notification
mNotifyBuilder
.setContentText("New message on your property, Check it");
// Set autocancel
mNotifyBuilder.setAutoCancel(true);
// Post a notification
mNotificationManager.notify(notifyID, mNotifyBuilder.build());
// mNotifyBuilder.build().sound = Uri
// .parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
// + getPackageName() + "/raw/kalimba");
// Uri uri =
// RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
//
// builder.setSound(uri);
} else {
Log.d("Notification-msssg", msg + "property");
Log.d("Notification-msssgproperty", msg);
Intent resultIntent = new Intent(this, ResidencialActivity.class);
resultIntent.putExtra("msg", msg);
PendingIntent resultPendingIntent = PendingIntent.getActivity(this,
0, resultIntent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder mNotifyBuilder;
NotificationManager mNotificationManager;
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotifyBuilder = new NotificationCompat.Builder(this)
.setContentTitle("CPO")
.setContentText("You've new Property to check")
.setSmallIcon(R.drawable.iconnotifi);
// Set pending intent
mNotifyBuilder.setContentIntent(resultPendingIntent);
// Set Vibrate, Sound and Light
int defaults = 0;
defaults = defaults | Notification.DEFAULT_LIGHTS;
defaults = defaults | Notification.DEFAULT_VIBRATE;
defaults = defaults | Notification.DEFAULT_SOUND;
mNotifyBuilder.setDefaults(defaults);
// Set the content for Notification
mNotifyBuilder.setContentText("New Property Added, Check it");
// Set autocancel
mNotifyBuilder.setAutoCancel(true);
// Post a notification
mNotificationManager.notify(notifyID, mNotifyBuilder.build());
}
}
}
if条件不能正常工作,我不知道问题是什么,它总是在条件的其他部分,检查值是正确的但不是pic如果部分..但是当我把它改成msg。等于(msg),而不是pic if if part ..
此检查用于更改通知获取的启动活动,我必须通知活动以获取活动..
针对此问题的任何解决方案......
答案 0 :(得分:0)
您正在调用方法为sendNotification(“发送错误:”+ extras.toString());.所以msg字符串包含“发送错误:......”。然后它如何变得等于“财产”???
答案 1 :(得分:0)
您认为msg应该等于"属性"?
您正在发送以下3条消息:
Referenced Libraries
没有单行发送值"属性"像这样:
Build Path