【问题标题】:Notifications don't work on android 4.3?通知在 android 4.3 上不起作用?
【发布时间】:2013-10-15 22:51:23
【问题描述】:

我实现了来自 Google 通知示例的代码示例。它在 Android 4.2.2 之前运行良好,但从 4.3 开始就不行了(在我的 Nexus 7 2013 上)......我是唯一一个遇到这个问题的人吗?我错过了新的通知方法吗?这是我的简单代码:

    final int NOTIFICATION_ID = 1;
        NotificationManager mNotificationManager;

        mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, HomeActivity.class), 0);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.icon)
        .setContentTitle("Title")
        .setStyle(new NotificationCompat.BigTextStyle()
        .bigText(""))
        .setContentText("Message");

        mBuilder.setContentIntent(contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());

谢谢!

【问题讨论】:

    标签: notifications android-4.3-jelly-bean


    【解决方案1】:

    事实上,问题出在我的 php 文件编码错误,无论出于何种原因,它都会跳过向数据库添加新用户 (registration_id) 的请求。 GCM 服务器无法知道我的设备,因为它没有添加到数据库中......

    关键是它可以在 Android 4.3 中运行!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多