- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
Android setFullScreenIntent() execute the PendingIntent when notification reach and phone is locked.
当我使用 setFullScreenIntent()
时遇到的奇怪问题它会执行 PendingIntent
,当我的手机被锁定时,当我解锁我的手机然后应用程序时,我已经设置为内容被打开。如果手机解锁并收到通知,它将在所有屏幕上将通知显示为顶部,并且不执行 PendingIntent
。有人遇到过这个问题吗?您的建议将不胜感激。
下面是我的代码
Intent _intent = new Intent(GcmIntentService.this,NotificationActivity.class);
_intent.addCategory(Intent.CATEGORY_DEFAULT);
_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mNotificationManager =(NotificationManager)GcmIntentService.this.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(GcmIntentService.this, requestCode,
_intent, PendingIntent.FLAG_UPDATE_CURRENT);
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(icon)
.setTicker(ticker)
.setContentTitle(title)
.setContentText(content)
.setAutoCancel(true)
.setWhen(System.currentTimeMillis())
.setDefaults(Notification.DEFAULT_ALL)
.setContentIntent(contentIntent);
if(CURRENT_VERSION>=LOLLIPOP_VERSION){
builder.setColor(Color.argb(255, 117,63,0));
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
builder.setSmallIcon(R.drawable.app_notification_icon);
builder.setFullScreenIntent(contentIntent, false);
}
mNotificationManager.notify(NOTIFICATION_ID, builder.build());
最佳答案
它不适用于我的 Android 8.1。如果将 intent 设置为 null,它将成为普通通知,而不会保留在单挑区域。
builder.setFullScreenIntent(null, true);
关于Android setFullScreenIntent() 在通知到达和手机锁定时执行 PendingIntent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31086400/
我想了解 PendingIntent.FLAG_NO_CREATE 的行为。我想知道它什么时候返回 null 什么时候不返回。这是事件发生的顺序: alarmIntent = new Intent(c
我正在尝试请求网络,因此我构建了 NetworkRequest 并构建了 PendingIntent, ConnectivityManager conn_manager = (Connectivit
我一直在使用警报管理器。一旦我设置了一个 PendingIntent 来触发警报,我想取消它。 How do I achieve this? 帮助将不胜感激。 最佳答案 下面这几行代码肯定可以帮助您删
我正在尝试在 Android 中创建一个 PendingIntent。这是代码 mNotificationIntent = new Intent(getApplicationContent(), My
我有三个 Activity (Home、Search、Destination),我可以用它们来描述我的用户体验流程。 Home Activity 是我的启动器 Activity ,然后是搜索 Acti
我试图从 API 中了解 PendingIntent 的用途。 有时我使用的一些方法需要这样做,但我仍然没有得到正确的想法。 谁能解释一下吗?为什么我不能只使用上下文? 谢谢 莫希克 最佳答案 Pen
我在 Android 中开发闹钟时遇到问题。当我触发包含必须在计划时间启动的 Activity 的 PendingIntent 时,它运行良好。但是,当闹钟响起并且我按贪睡 5 分钟并使用不同的请求代
我得到了一个 IntentService,它在 onHandleIntent(Intent) 中同步执行一些长时间运行的工作。因此,只要服务运行,我就会显示一个通知。现在我想在用户点击通知后停止服务。
我有这个... button = (Button) findViewById(R.id.start_repeating); button.setOnClickListener(new OnClickL
在我的应用程序中,我有一个显示 2 个选项的对话框:Copy 和 Dismiss 当用户单击 Copy 时,我希望在状态栏中收到通知。 public void showDialog(final Str
我有一个会显示通知的服务。通知显示正确,但当我点击通知时没有任何反应。它应该在我的应用程序中打开一个 Activity 。这是我的代码: public class ServiceCheckExpens
我正在我的游戏中创建一个通知。如果玩家有一段时间没有玩游戏,我想显示通知。我正在使用以下带有警报设置的 PendingIntent 来创建通知。有了这个,我就可以创建通知。 问题:如果玩家玩游戏,我需
所以这段代码是在我的服务开始在前台启动后从内部运行的。这也会创建将留在那里的通知。我有很多问题/疑问: 1) 点击通知只会打开应用信息,不会打开我的 PendingIntent。 2) 未设置我的内容
如何创建多个 PendingIntent?我有几个通知,当用户按下最后一个通知时,一切正常,但点击通知没有响应。我的代码是: Intent notificationIntent = new Inten
我正在运行一项服务,该服务会在特定事件的通知栏上发出通知。在该通知中,我设置了一个 PendingIntent 以启动另一个应用程序。出于某种原因,当我根据通知采取行动时,它不会启动其他应用程序。这是
我有一个名为 sendNotification 的方法,可以多次调用。 private PendingIntent createNotificationIntent(Context context,
我有一个导航应用程序。我想获得可能暂时不会到达的位置信息,具体取决于 GPS 锁定所需的时间——或者接收信号不好时的时间。 我计划使用 LocationManager.requestLocationU
我有一个 Android 库,它有一个创建 Notification 的 Service。据我了解,Notification 必须有一个 contentIntent (PendingIntent) 集
当我们将 0 作为标志传递给 PendingIntent 时,如下所示: PendingIntent pi=PendingIntent.getActivity(this, 1, i, 0); does
我在尝试通过 Intent 和未决 Intent 将数据传递给 BroadcastReceiver 时遇到了一些问题,涉及接近警报。更具体地说,我试图传递一个对象,其中包括用户不断变化的位置。我已经尝
我是一名优秀的程序员,十分优秀!