Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
751 views
in Technique[技术] by (71.8m points)

android - Strange allow/deny question on Huawei 5.1 phone when showing notification

So it turns out that Huawei phones with 5.1 can't display MediaStyle notifications so while fixing that, I made a very simple notification test and I get a strange question asking Allow App Name to push messages to the notification panel.

I don't use push in any way, in fact the screenshot below is for an app that all it does is show a sample notification, nothing else.

How can I make it not show that?

This is the code:

 Notification notification = new Notification.Builder(getApplicationContext())
                .setSmallIcon(R.drawable.ic_launcher_background)
                .setContentTitle("Track title")
                .setContentText("Artist - Album")
                .setOngoing(true)

                .addAction(R.drawable.ic_add_black_24dp, "fwd", pi)
                .addAction(R.drawable.ic_android_black_24dp, "fwd", pi)
                .addAction(R.drawable.ic_archive_black_24dp, "fwd", pi)
                .addAction(R.drawable.ic_arrow_back_black_24dp, "fwd", pi)
                .addAction(R.drawable.ic_aspect_ratio_black_24dp, "fwd", pi)
                .addAction(R.drawable.ic_fast_forward_black_24dp, "fwd", pi)
                .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.vectors_525058875))
                .setAutoCancel(false)


                .build();
        notificationManager.notify(300, notification);

This is the screenshot.

enter image description here

What am I doing wrong? I tried taking out all the actions, that didn't help. Took out title and context, that didn't help. Took out large icon, auto cancel, ongoing, etc, didn't help.

Please note that I am not using Push in any way and this doesn't seem to be related to that. Also I a using the support compat libraries to make my notification but on this example I didn't just to make sure that wasn't the issue.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Huawei's version of the Android OS has a custom feature that tries to spot apps doing annoying numbers of notifications.

Don't focus on the word "push". It doesn't mean "push notifications" in the technical sense of coming from the internet. It just is a verb, they could have said "allow app to create notifications" or "allow app to cause notifications" it's the same meaning.

Anyway, this is an OS feature, there is nothing you can do to avoid it except make sure you aren't spammy with your notifications. Unfortunately during development and testing you will often be triggering a lot of notifications, and the OS will detect your app is spammy. Don't worry about it. As long as your app works well for normal users it shouldn't happen.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...