我已经尝试了这3天的android通知工作,用户点击通知然后活动打开.但每次我举杯,它都说是空的.尝试使用SOF的一些解决方案,但不起作用.你能看看代码有什么问题吗?提前致谢.
通知代码是
private void sendPushNotification(JSONObject json) {
//optionally we can display the json into log
int notificationId = new Random().nextInt();
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");
// Instantiate a Builder object.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this.getApplicationContext(),"Default");
Intent notifyIntent = new Intent(this, MainActivity.class);
notifyIntent.putExtra("fromNotification", true);
// Sets the Activity to start in a new, empty task …Run Code Online (Sandbox Code Playgroud)