1

我在处理锁定屏幕上的推送通知页面时遇到问题。Android:在推送通知页面后打开浏览器外部

我创造了我的应用程序GCM模模块,MyAppGcmListenerService类扩展GcmListenerServiceonMessageReceived方法我处理正在进行捆绑

@Override 
    public void onMessageReceived(String from, Bundle data) { 
     logger.info("MyAppGcmListenerService: onMessageReceived: from = " + from + "; data = " + data.toString()); 
     sendNotification(createMessage(data)); 
    } 

private void sendNotification(Message message) { 
    Intent intent = null; 

    if (TextUtils.isEmpty(message.getUrl())) { 
     intent = new Intent(this, MainActivity.class); 
     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    } else { 
     intent = new Intent(Intent.ACTION_VIEW); 
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     intent.setData(Uri.parse(Utils.buildUrlWithExtraInfo(message.getUrl(), Prefs.restoreGuid()))); 
    } 
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); 

    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
      .setSmallIcon(R.drawable.notif_small_icon) 
      .setColor(getBaseContext().getResources().getColor(R.color.notif_bg_color)) 
      .setContentTitle(message.getTitle()) 
      .setContentText(message.getParagraph()) 
      .setAutoCancel(true) 
      .setSound(defaultSoundUri) 
      .setContentIntent(pendingIntent); 

    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
    manager.notify(0, notificationBuilder.build()); 
} 

一切正常时,我点击通知栏中的推送通知 - 我收到非空网址和外部推送浏览器打开我的网址。当我点击锁定屏幕(Android 5+)上的通知时会出现问题 - 在这种情况下,我建议“刷屏解锁”,然后不运行浏览器打开网址。

有没有人khow如何解决这个问题?

UPD。在这两种情况下,启动应用程序(MainActivity.class)都会顺利进行:当点击通知栏和锁定屏幕上的通知时。

+0

根据你的更新评论,你说它的在这两种情况下进展顺利。我们需要解决什么问题吗? –

+0

是的,问题是实际的。在这两种情况下启动应用程序都很顺利,但是当我尝试在锁定屏幕上打开浏览器轻击按钮时 - 它失败了,浏览器未打开。 –

回答

1

您是否将Chrome用作设备上的默认浏览器? 如果是这样,而在锁屏所看到here

我仍然试图找到解决类似的问题,这可能是浏览器忽略收到意图的问题,我也试图将意向发送到虚活动是当onResume()被调用时(onResume被调用,当活动在前面并且对用户可见时),但是Chrome以某种方式仍然忽略了这个意图,然后启动Chrome ...

相关问题