通知:索尼设备不显示任何通知 [英] Notification: Sony devices do not show any notification

查看:224
本文介绍了通知:索尼设备不显示任何通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用code这几行用于显示通知,在我的应用程序,但索尼设备(XPERIA磷,索拉,ACRO S)不显示任何通知。我没有与其他Android设备的任何问题。

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 devices.

Intent notificationIntent = new Intent(context, ActivityShowQuestion.class);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent contentIntent = PendingIntent.getActivity(context,
            Integer.parseInt(id), notificationIntent,
            PendingIntent.FLAG_ONE_SHOT);

    NotificationManager nm = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    Notification.Builder builder = new Notification.Builder(context);

    builder.setContentIntent(contentIntent)
            .setSmallIcon(R.drawable.ic_launcher)
            .setWhen(System.currentTimeMillis())
            .setAutoCancel(true)
            .setContentTitle("title")
            .setContentText("text");
    Notification n = builder.build();

    nm.notify(id, n);

我用Google搜索,但未能找到任何答案。

I googled for it but could not found any answer.

推荐答案

这是从广播我onRecieve,它使得在XPERIA通知,我还没有过任何与它的设备问题,如果你的作品,你可以砍它

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



}

它不使用生成器IDK的究竟是什么原因造成您的问题,我知道这个工程对XPERIA虽然

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

这篇关于通知:索尼设备不显示任何通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆