自动使用BigTextStyle开幕活动setFullScreenIntent()通知 [英] Notification using setFullScreenIntent() for BigTextStyle opening Activity automatically

查看:2302
本文介绍了自动使用BigTextStyle开幕活动setFullScreenIntent()通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很奇怪的问题,我在推送通知工作,这是成功实施,但是当我用BigTextStyle的通知显示在通知区域与setFullScreenIntent()方法的长消息那么问题来了通知开幕活动将自动被设置在的PendingIntent。

如果我不使用setFullScreenIntent()则通知将不开放活动自动用户必须点击或单击通知以打开活动中的PendingIntent设置。

因此​​有两个codeS


  1. 无setFullScreenIntent()工作的罚款,而不是自动打开活动:

     的通知=新NotificationCompat.Builder(上下文)
                            .setContentTitle(标题)
                            .setContentIntent(resultPendingIntent)
                            .setContentText(消息)
                            .setStyle(
                                    新NotificationCompat.BigTextStyle()
                                            .bigText(消息))
                            .setSmallIcon(R.drawable.ic_launcher)
                            .setAutoCancel(真);
    NotificationManager经理=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
                manager.notify(1,notification.build());


  2. 通过setFullScreenIntent()也工作正常,但开幕活动自动: -

     的通知=新NotificationCompat.Builder(上下文)
                            .setContentTitle(标题)
                            .setContentIntent(resultPendingIntent)
                            .setContentText(消息)
                            .setStyle(
                                    新NotificationCompat.BigTextStyle()
                                            .bigText(消息))
                            .setSmallIcon(R.drawable.ic_launcher)
                            .setFullScreenIntent(resultPendingIntent,真)//不管是真的还是假的结果相同
                            .setAutoCancel(真);
    NotificationManager经理=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
                manager.notify(1,notification.build());



解决方案

  

公共NotificationCompat.Builder setFullScreenIntent(的PendingIntent意图,布尔高优先级)


  
  

这是有意推出,而不是张贴通知状态
  酒吧。仅适用于具有非常高的优先通知,要求使用
  用户立即关注,例如传入的电话呼叫或
  闹钟用户已经明确地设定为一个特定的时间。如果
  这个设施是用于别的东西,请给用户一个
  选项​​将其关闭,并使用一个正常的通知,因为这可能是
  极大的干扰。


  
  

在某些平台上,系统UI可以选择显示抬头
  通知的,而不是推出这一意图,而用户
  使用该设备


  
  

参数


  
  

目的:的挂起的意图推出。


  
  

高优先级:的传递
  如此将导致此通知中,即使对方发
  通知燮pressed。


找到<一href=\"http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setFullScreenIntent(android.app.PendingIntent,%20boolean)\"相对=nofollow>此处。正如你可以看到它立即启动意图。我真的不知道你想要使用什么样的情况下 setFullScreenIntent()

在显示在顶部的静态通知(可与WiFi,蓝牙和声音控制来定制吧)

的通知不会自动展开

I have a very strange issue, I am working on Push Notification and it was successfully implemented but when i have used BigTextStyle in Notification to show a long message in notification area with setFullScreenIntent() method then the issue coming up the Notification opening the Activity automatically which is set in PendingIntent.

If I don't use setFullScreenIntent() then notification won't opening Activity automatically the user has to tap or click on Notification to open the Activity set in PendingIntent.

So there are two codes

  1. Without setFullScreenIntent() working fine and not opening Activity automatically:

    notification = new NotificationCompat.Builder(context)
                            .setContentTitle("Title")
                            .setContentIntent(resultPendingIntent)
                            .setContentText(message)
                            .setStyle(
                                    new NotificationCompat.BigTextStyle()
                                            .bigText(message))
                            .setSmallIcon(R.drawable.ic_launcher)
                            .setAutoCancel(true);
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                manager.notify(1, notification.build());
    

  2. With setFullScreenIntent() also working fine but opening Activity automatically:-

    notification = new NotificationCompat.Builder(context)
                            .setContentTitle("Title")
                            .setContentIntent(resultPendingIntent)
                            .setContentText(message)
                            .setStyle(
                                    new NotificationCompat.BigTextStyle()
                                            .bigText(message))
                            .setSmallIcon(R.drawable.ic_launcher)
                            .setFullScreenIntent(resultPendingIntent, true) //Whether true or false same result
                            .setAutoCancel(true);
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                manager.notify(1, notification.build());
    

解决方案

public NotificationCompat.Builder setFullScreenIntent (PendingIntent intent, boolean highPriority)

An intent to launch instead of posting the notification to the status bar. Only for use with extremely high-priority notifications demanding the user's immediate attention, such as an incoming phone call or alarm clock that the user has explicitly set to a particular time. If this facility is used for something else, please give the user an option to turn it off and use a normal notification, as this can be extremely disruptive.

On some platforms, the system UI may choose to display a heads-up notification, instead of launching this intent, while the user is using the device.

Parameters

intent: The pending intent to launch.

highPriority: Passing true will cause this notification to be sent even if other notifications are suppressed.

Found here. As you can see it immediately launches the intent. I don't really know in what case you wanted to use setFullScreenIntent()?

A notification won't automatically expand when a static notification is displayed on top (could be custom bar with wifi, bluetooth and sound control)

这篇关于自动使用BigTextStyle开幕活动setFullScreenIntent()通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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