所有我这是我的通知类中的代码,我从第一次活动完成我的任务后调用。Android中的通知问题?
但我遇到了当前应用程序获取通知的问题。
我想显示通知作为对话框。
"R.layout.main"
包含带确定按钮的对话框。
public class Notif extends Activity implements View.OnClickListener {
private Button Button01;
private NotificationManager mManager;
private static final int APP_ID = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.Button01 = (Button) this.findViewById(R.id.Button1);
this.Button01.setOnClickListener(this);
mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
}
@Override
public void onClick(View v) {
Intent intent = new Intent(this,Notif.class);
Notification notification = new Notification(R.drawable.icon,
"Notify", System.currentTimeMillis());
notification.setLatestEventInfo(Notif.this,"App Name","Description of the notification",PendingIntent.getActivity(this.getBaseContext(), 0, intent,
PendingIntent.FLAG_CANCEL_CURRENT));
mManager.notify(APP_ID, notification);
}
}
感谢您对我的时间...实际上,我已创建活动,其中我有进度条,其中有一个最大限制..所以在达到进度条到最大值我想显示消息box.it必须看到任何当前的应用程序..因此,这是你想创建对话框作为通知..请帮助我实现它... – Smith 2011-03-17 11:55:59
你想创建一个通知和一个弹出框?我真的认为你应该坚持创建一个通知,他们很难错过,并应该很好地通知用户(这是他们的目的)。然后你可以在你的活动中弹出一个对话框,如果你需要从那里显示更多的信息。我不认为你应该尝试从一个不重点的活动中做通知和对话框(理想情况下,你应该做一个服务的通知,我想,但这是另一回事)。 – Klaus 2011-03-17 12:08:18
@你的权利,但我可以在屏幕中间显示消息窗口作为通知,我想把按钮放在该消息框.....请帮助实现它 – Smith 2011-03-17 12:19:42