Notification: Sony devices do not show any notification

前端 未结 1 1025
忘掉有多难
忘掉有多难 2021-01-24 18:24

I use these lines of code for showing notification in my app but sony devices(xperia p, sola, acro s) does not show any notification. I dont have any problem with other android

相关标签:
1条回答
  • 2021-01-24 18:41

    This is my onRecieve from a Broadcast, it makes notifications on xperia, i havent had any device problems with it you can chop it up if it works for you

    @Override
        public void onReceive(Context arg0, Intent arg1) {
            String key = LocationManager.KEY_PROXIMITY_ENTERING;
    
            Boolean entering = arg1.getBooleanExtra(key, false);
            String here = arg1.getExtras().getString("alert");
            String happy = arg1.getExtras().getString("type");
    
    
    
             NotificationManager notificationManager = 
                        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    
                    PendingIntent pendingIntent = PendingIntent.getActivity(arg0, 0, arg1, 0);        
    
                    Notification notification = createNotification();
    
                    notification.setLatestEventInfo(arg0, 
                        "Entering Proximity!", "You are approaching a " + here + " marker.", pendingIntent);
    
                    notificationManager.notify(NOTIFICATION_ID, notification);
    
    
                }
    
                private Notification createNotification() {
                    Notification notification = new Notification();
    
                    notification.icon = R.drawable.icon;
                    notification.when = System.currentTimeMillis();
    
                    notification.flags |= Notification.FLAG_AUTO_CANCEL;
                    notification.flags |= Notification.FLAG_SHOW_LIGHTS;
    
                    notification.defaults |= Notification.DEFAULT_VIBRATE;
                    notification.defaults |= Notification.DEFAULT_LIGHTS;
    
                    notification.ledARGB = Color.WHITE;
                    notification.ledOnMS = 1500;
                    notification.ledOffMS = 1500;
    
    
                    return notification;
                }
            //make actions
    
    
    
    }
    

    it doesnt use Builder idk exactly what is causing your problem, i know this works on xperia though

    0 讨论(0)
提交回复
热议问题