【发布时间】:2019-06-17 11:09:33
【问题描述】:
我使用 switch case 进行条件检查。它不工作。这是我的实施方式。
@Override
public void onReceiveNotification(String notificationType, String message, String flag) {
super.onReceiveNotification(notificationType, message, flag);
Log.d("tag", "==onReceive Notivation====1===" + notificationType);
if (notificationType.equalsIgnoreCase("MULTIPART_TYPES"))
{
Log.d("tag", "==onReceive Notivation===2====" + notificationType);
}
switch (notificationType) {
case "MULTIPART_TYPES":
Log.d("tag", "==onReceive Notivation=======" + message);
break;
}
}
这是我的日志输出
==onReceive Notivation====1=== MULTIPART_TYPES
但是它正在进入带有尊重字符串消息的方法。但它并没有进入切换或if条件。
【问题讨论】:
-
你能添加你的日志输出吗?
-
@jbarat,我添加了 log out 。请检查
-
将 else 条件放在 if 块中,默认放在 switch 中。并检查它是否进入 else 或 default 块。
-
有一个领先的soace。仔细看。
标签: java android if-statement switch-statement