可以用Threadnew Thread(){
@Override
public void run(){synchronized(this)
{
try
{
wait(5000); //5秒
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
finish(); }
}.start();
@Override
public void run(){synchronized(this)
{
try
{
wait(5000); //5秒
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
finish(); }
}.start();
退出应用就参考退出应用的代码了。
http://blog.csdn.net/forlong401/article/details/7519483
用AlarmManager好像只能配合Intent使用额?
Intent intent=new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
System.exit(0);
http://stackoverflow.com/questions/4459058/alarm-manager-example
在每个Activity里面注册一个相同名称的广播接收机,要退出的话发送广播,所有Activity收到广播后执行finish();
这个。。
怎么给他们发送广播?他们收到广播后怎么执行啊
然后在每个activity中,
1. new broadcastreveiver.
2. filter intent;
filter.addAction(QUIT_APPLICATIONS );
register receiver.
3.在onReceive中
if (QUIT_APPLICATIONS .equals(action)) {
finish();
}