0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ホーム画面のアプリアイコンに通知数などを表示する(バッジ)【Kotlin】

Posted at

ShortcutBadgerというライブラリを使用して表示させます!

手順は公式のGithubにある通り進めていきます。

準備

build.gradleに

build.gradle
android {

    repositories {
        mavenCentral()
    }
}

dependencies {
    implementation "me.leolin:ShortcutBadger:1.1.22@aar"
}

↑を追加

準備の際いろいろ手こずったのですが、詳しくは以下などを参考にしてください

実践

var badgeCount = 10
ShortcutBadger.applyCount(applicationContext, badgeCount)

とすることで、アプリアイコンに10のバッジがつきます。

消したい時は、

ShortcutBadger.removeCount(applicationContext)

もしくは、
applyCountで渡す値を0にすると消える。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?