我想从 android 中的通知栏调用 android 对话框而不是导致 url。这是我用来从通知调用 url 的代码。告诉我如何为对话框执行此操作。谢谢
notifyDetails.defaults |= Notification.DEFAULT_ALL;
Context context = getApplicationContext();
CharSequence contentTitle = "Notification Details...";
CharSequence contentText = "Browse Android Official Site by clicking me";
Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));
PendingIntent intent =
PendingIntent.getActivity(SimpleNotification.this, 0,
notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent);
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
最佳答案
只需让 pendingintent 打开您的 Activity 之一,让您的 Activity 完全透明,然后打开一个对话框即可。
编辑 向 Intent 添加标志
Intent notifyIntent = new Intent(context,YourActivityClassHere.class);
notifyIntent.setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);
//UNIQUE_ID if you expect more than one notification to appear
PendingIntent intent = PendingIntent.getActivity(SimpleNotification.this, UNIQUE_ID,
notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
关于android - 如何从android中的通知栏调用对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8146680/