我无法比较价值。问题是我在FirebaseMessagingService中收到了Id值,在Activity中收到了Id值。如果它们相等,则需要比较这两个值。您能指导我如何创建一些东西,也许是可以在Activity和服务之间传递此值的帮助器类吗?
服务类中的onMessageReceived():
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
String message = remoteMessage.getData().get("message");
String title = remoteMessage.getData().get("title");
String conId = remoteMessage.getData().get("conId");
Intent intent = new Intent("Use anything you like");
intent.putExtra("data","The data you receive");
sendBroadcast(intent);
sendNotification(message, title, conId);
Log.d(TAG, message + " " + title);
}
活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_conversation);
setTitle("Rozmowa");
conId = getIntent().getStringExtra("conId");
我需要比较如果Service中的conId与Activity中的Extras中的conId相等,那么是否将不调用true sendNotification()。