Android退出动画下广告不出错详解
--------不加任何权限 AD
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
Intent i = new Intent(Intent.ACTION_MAIN);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addCategory(Intent.CATEGORY_HOME);
startActivity(i);
}
------------电视动画
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
if (item.getItemId() == 1) {
AlertDialog.Builder builder = new
Builder(caipiaoActivity.this);
builder.setTitle("福彩3D,体彩排列软件信
息");
builder.setMessage(R.string.about);
builder.create().show();
} else {
mLinearLayout.startAnimation(new
TVOffAnimation());
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated
method stub
android.os.Process.killProcess(android.os.Process.myPid());
}
}, 1000);
}
return true;
}
-------------返回
public boolean onKeyDown(int keyCode, KeyEvent event)
{
// TODO Auto-generated method stub
// return
super.onKeyDown(keyCode, event);
if (keyCode ==
KeyEvent.KEYCODE_BACK)
{
new
AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(R.string.loginout_title)
.setMessage(R.string.loginout_msg)
.setPositiveButton(
R.string.confirm,
new android.content.DialogInte易做图ce.OnClickListener()
{
@Override
public void onClick
(DialogInte易做图ce dialog,
int which)
{
// TODO Auto-generated method
stub
Intent startMain = new Intent(
Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
System.exit(0);
}
}).setNegativeButton(R.string.cancel, null)
.create().show();
return false;
}
return false;
}
-------------动画总结
加推送广告 安装之后杀了进程不会弹出窗口,关闭动画播放正常.
删除返回值.
public void onBackPressed() {
// TODO Auto-generated method stub
AlertDialog.Builder builder = new
Builder(caipiaoActivity.this);
builder.setTitle("提示");
builder.setMessage("是否要退出福彩3D体彩排列软
件");
builder.setPositiveButton("确定",
new
android.content.DialogInte易做图ce.OnClickListener() {
@Override
public void onClick
(DialogInte易做图ce dialog, int which) {
// TODO Auto-
generated method stub
mLinearLayout.startAnimation(new TVOffAnimation());
new Timer
().schedule(new TimerTask() {
@Override
public
void run() {
// TODO Auto-generated method stub
android.os.Process
.killProcess(android.os.Process.myPid());
}
}, 1000);
}
}).setNegativeButton("取消",
null);
builder.create().show();
}
------------退出不加入动画 AD推送安装正常,直接安装不出现弹出窗口
再自动关回.
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
Intent i = new Intent(Intent.ACTION_MAIN);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addCategory(Intent.CATEGORY_HOME);
startActivity(i);
摘自 gongzibai的专栏
补充:移动开发 , Android ,