如何关闭/停止运行的背景Android应用程序 [英] how to close/stop running application on background android

查看:141
本文介绍了如何关闭/停止运行的背景Android应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要关闭或停止运行的应用程序,当我从主屏幕上的退出意味着应用程序的第一个布局的时候我preSS后退按钮的机器人。 我用这个,但我的应用程序在后台运行

  @覆盖
    公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
       //闪屏视图
        的setContentView(R.layout.splash);
        }


 **公共无效的onDestroy()
  {
 super.onDestroy();
 System.runFinalizersOnExit(真正的);
 System.exit(0);
    } **
 

解决方案

让你的应用程序的进程ID,并杀死该进程的onDestroy()方法

  @覆盖
公共无效的onDestroy()
 {
    super.onDestroy();

    INT的id = android.os.Process.myPid();
    android.os.Process.killProcess(ID);
 }
 

i want to close or stop running application when i exit from main screen means very first layout of application when i press back button in android. i use this but my application is running on background

        @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
       // Splash screen view
        setContentView(R.layout.splash);
        }


 **public void onDestroy()
  {
 super.onDestroy();
 System.runFinalizersOnExit(true);
 System.exit(0);
    }**

解决方案

get the process ID of your application, and kill that process onDestroy() method

@Override
public void onDestroy()
 {
    super.onDestroy();

    int id= android.os.Process.myPid();
    android.os.Process.killProcess(id);
 }

这篇关于如何关闭/停止运行的背景Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆