我有一个服务,有时称为显示alertdialog的活动..当点击确定按钮时,我想要去我的应用程序的活动在屏幕上,或者,如果我的应用程序是不是在前面,回过头来用户在显示窗口..这是我的alertdialog如何隐藏从服务调用的活动android
public class ActivityNotification extends Activity{
private String client,notifica;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
client = getIntent().getStringExtra("client");
notifica = getIntent().getStringExtra("notifica");
final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Notifica da "+client);
alertDialog.setMessage(notifica);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
alertDialog.cancel();
}
});
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
}
}
这就是我把这个活动从服务的方式
Notification notification = new Notification(R.drawable.icon, "Notifica da "+client, 10000);
notification.flags |=Notification.FLAG_AUTO_CANCEL;
CharSequence contentTitle = "Notifica da "+client;
CharSequence contentText = notifica;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
//Intent notificationIntent = new Intent(this,ActivityNotification.class);
Intent notificationIntent = new Intent();
notificationIntent.setClassName("package", "package.ActivityNotification");
notificationIntent.putExtra("client",client);
notificationIntent.putExtra("notifica",notifica);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,0);
notification.setLatestEventInfo(this, contentTitle, contentText, contentIntent);
mManager.notify(id, notification);
什么都可以我做?你能帮我吗?
使用moveTaskToBack? :) – JackTurky 2011-12-16 07:51:49