なぜ通知は、API 28に表示されませんか?

Noobcoder:

しかし、私は通知が、私は表示されませ表示するようにしようとしています理由を理解するように見えることはできませんが、私はAndroidのドキュメントを見ていると私はStackOverflowの中にすべての答えを見てきました。たび私は、ボタンをクリックして、代わりに通知現れて、アプリがクラッシュし、缶誰かがなぜこれが起こっているのと私に洞察力を与えてください?

notify_me.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                        NotificationChannel channel = new NotificationChannel("miscellaneous", "Hello World", NotificationManager.IMPORTANCE_HIGH);
                        channel.setDescription("Hello Brothers and Sisters");
                        NotificationManager noti = getSystemService(NotificationManager.class);
                        noti.createNotificationChannel(channel);
                    }
                }
            }
    );

ここでは、スタックトレースがあります

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.test, PID: 27996
java.lang.IllegalArgumentException: Reserved id
    at android.os.Parcel.createException(Parcel.java:1970)
    at android.os.Parcel.readException(Parcel.java:1934)
    at android.os.Parcel.readException(Parcel.java:1884)
    at android.app.INotificationManager$Stub$Proxy.createNotificationChannels(INotificationManager.java:1888)
    at android.app.NotificationManager.createNotificationChannels(NotificationManager.java:577)
    at android.app.NotificationManager.createNotificationChannel(NotificationManager.java:565)
    at com.example.test.Main4Activity$1.onClick(Main4Activity.java:44)
    at android.view.View.performClick(View.java:7352)
    at android.widget.TextView.performClick(TextView.java:14177)
    at android.view.View.performClickInternal(View.java:7318)
    at android.view.View.access$3200(View.java:846)
    at android.view.View$PerformClick.run(View.java:27800)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7050)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
 Caused by: android.os.RemoteException: Remote stack trace:
    at com.android.server.notification.RankingHelper.createNotificationChannel(RankingHelper.java:641)
    at com.android.server.notification.NotificationManagerService$12.createNotificationChannelsImpl(NotificationManagerService.java:2585)
    at com.android.server.notification.NotificationManagerService$12.createNotificationChannels(NotificationManagerService.java:2600)
    at android.app.INotificationManager$Stub.onTransact(INotificationManager.java:292)
    at android.os.Binder.execTransact(Binder.java:739)
ianhanniballake:

エラーメッセージごとに、あなたが使用することはできません"miscellaneous"あなたの通知チャネルのIDとして-その名は、特にそれらに接続チャネルを持っていないすべての通知を掲示するためのAPI 26以上を対象としていないアプリケーションのために予約されています。

あなたのチャンネルのために、他のID文字列を使用することができます。

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=232042&siteId=1