由网友(老衲用飘柔)分享简介:如何杀死的Onne单一的点击整个应用程序..完成()不工作?它重定向到塔previous活动...请指引我。公共无效的onClick(查看为arg0){// TODO自动生成方法存根WallpaperManager WP = WallpaperManager.getInstance(getApplicationCont...
如何杀死的Onne单一的点击整个应用程序..完成()不工作?它重定向到塔previous活动...请指引我。
公共无效的onClick(查看为arg0){
// TODO自动生成方法存根
WallpaperManager WP = WallpaperManager
.getInstance(getApplicationContext());
尝试 {
显示D =((窗口管理器)getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
INT宽度= d.getWidth();
INT高= d.getHeight();
wp.setBitmap(B1);
}赶上(IOException异常E){
Log.e(错误,无法设置图片作为壁纸,E);
}
完();
}
解决方案
System.exit()的
不杀你的应用程序,如果你有一个以上的活动在堆栈上
使用 android.os.Process.killProcess(android.os.Process.myPid());
这样
样品
公共无效onBack pressed(){
android.os.Process.killProcess(android.os.Process.myPid());
super.onBack pressed();
}
有关详细请参阅Quitting一个应用程序 - 这是令人难以接受的,How逼停我的Android应用程序编程?
我希望这会帮助你。
How to kill whole application in onne single click.. finish() is not working?? it redirects to tha previous activity...pls guide me.
public void onClick(View arg0) {
// TODO Auto-generated method stub
WallpaperManager wp = WallpaperManager
.getInstance(getApplicationContext());
try {
Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
int width = d.getWidth();
int height = d.getHeight();
wp.setBitmap(b1);
} catch (IOException e) {
Log.e("error", "Cannot set image as wallpaper", e);
}
finish();
}
解决方案
System.exit()
does not kill your app if you have more than one activity on the stack
Use android.os.Process.killProcess(android.os.Process.myPid());
this way.
for sample
public void onBackPressed() {
android.os.Process.killProcess(android.os.Process.myPid());
super.onBackPressed();
}
For more detail see Quitting an application - is that frowned upon? , How to force stop my android application programatically?
I hope this will help you.
相关推荐
最新文章