JSONObjectデータには、受け取ったファイヤーベースの通知メッセージがあります。通知はトレイに積み重ねられます。メッセージの最初の値は "Hi"で、メッセージの2番目の値は "Hello"です。私は両方の値を次の活動に送る必要があります。しかし、唯一の「こんにちは」(第二の値)は、次のアクティビティに印刷されAndroidのインテントを使用して次のアクティビティにデータを渡す
private void sendPushNotification(JSONObject json) {
//optionally we can display the json into log
Log.e(TAG, "Notification JSON " + json.toString());
try {
//getting the json data
JSONObject data = json.getJSONObject("data");
//parsing json data
String title = data.getString("title");
String message = data.getString("message");
String imageUrl = data.getString("image");
//creating MyNotificationManager object
MyNotificationManager mNotificationManager = new MyNotificationManager(getApplicationContext());
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
intent.putExtra("time",message);
//if there is no image
if(imageUrl.equals("null")){
//displaying small notification
mNotificationManager.showSmallNotification(title, message, intent);
}else{
//if there is an image
//displaying a big notification
mNotificationManager.showBigNotification(title, message, imageUrl, intent);
}
} catch (JSONException e) {
Log.e(TAG, "Json Exception: " + e.getMessage());
} catch (Exception e) {
Log.e(TAG, "Exception: " + e.getMessage());
}
HomeActivity.java
Intent i=getIntent();
String times = i.getStringExtra("time");
uは完全なコードを共有することができ、あなたが値を設定しているか、そしてどのようにあなたはそれを取得していますか? – Shekhar
両方の文字列に同じキーを使用するので、秒だけが保存されます。 –
私が与えた答えをお試しください。 – Shekhar