小编Kno*_*ing的帖子

android支持库中的芯片组件?

这个材料设计展示了关于芯片组件的案例.但是我找不到这个组件的示例代码?

我怎么用呢?

请告诉我XML代码和java代码.

android material-design android-chips

30
推荐指数
1
解决办法
2万
查看次数

onCreate() 和 onStartCommand() 中的 startForeground()

我遇到了 Playstore 报告的大量异常。来自 Android P 的 RemoteServiceException。

我正在创建 android 前台服务,然后调用 startForegound(with channel)。

但 99.9% 只有 9.0(android P) 用户报告 RemoteServiceException。我检查了我是否为该服务制作了通知渠道。我还检查了我是否在 OREO 之后为 os 调用了 startForegroundService。

每个代码都没有问题。

但是我发现我多次调用 startForegroundService() ,但是在第一次创建 Service 时只调用了一次 onCreate() 。所以 onCreate() 中的 startForeground() 只被调用一次。

但是,如果我将 startForeground() 放在 onStartCommand() 中,那么它的调用次数也将与我调用 startForegroundService() 的次数一样多。因为每当您调用 startService/startForegroundService 时它也会被调用(即使已经创建了 Service 的实例)。

你认为这是异常的原因吗?

而 mboy 对/sf/answers/3587621901/的评论 也说了类似的话。

android foreground-service remoteserviceexception android-9.0-pie

10
推荐指数
1
解决办法
1356
查看次数

如何在 startForeground() 时隐藏徽章计数

startForeground() 需要创建 NotificationChannel 以便它会在 Oreo 设备的启动器图标上显示徽章编号 1

如何以编程方式隐藏/禁用它?

因为 Galaxy S8(Oreo) 显示徽章编号 1。而 Android 8.0 模拟器也显示点。

这就是我现在所做的。但是 setShowBadge(false) 不起作用

编辑1:

        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        NotificationChannel tmpC = new NotificationChannel(id, "basic", NotificationManager.IMPORTANCE_MIN);
        tmpC.setShowBadge(false);

        manager.createNotificationChannel(tmpC);

        Notification notification = new NotificationCompat.Builder(this, id)
                .setChannelId(id)
                .setAutoCancel(true)
                .build();

        startForeground(getPackageName().hashCode(), notification);
Run Code Online (Sandbox Code Playgroud)

service android android-notifications notification-channel

7
推荐指数
2
解决办法
3637
查看次数

如何在android studio3中制作目标版本低于26(oreo)的apk?

我们使用私有应用程序商店,因此我们可以上传低于26目标sdk的应用程序。如何构建目标版本低于 26(oreo) 的 apk?

Android studio 3.3 显示构建发布错误。它说我应该使用目标 sdk 26 或更高版本。

android

1
推荐指数
1
解决办法
1357
查看次数