如何从android中的通知栏调用对话框?

时间:2011-11-16 04:20:04

标签: android notifications

我想从android中的Notification栏调用一个android对话框,而不是通向url.Here是我的代码,我用它来通知来调用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);

1 个答案:

答案 0 :(得分:1)

让pendingintent打开你的一个活动,让你的活动完全透明,然后打开一个对话框。

编辑为意图添加标记

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);