Example usage for android.os Process killProcess

List of usage examples for android.os Process killProcess

Introduction

In this page you can find the example usage for android.os Process killProcess.

Prototype

public static final void killProcess(int pid) 

Source Link

Document

Kill the process with the given PID.

Usage

From source file:com.example.alyshia.customsimplelauncher.MainActivity.java

@Override
protected void onDestroy() {
    super.onDestroy();
    unregisterReceiver(kioskReceiver);/*from  www . j  a  v  a  2  s .c o m*/
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        finishAndRemoveTask();
    }
    mKnoxThread.quit();
    Process.killProcess(Process.myPid());
}

From source file:org.zywx.wbpalmstar.engine.EBrowserActivity.java

private final void loadResError() {
    AlertDialog.Builder dia = new AlertDialog.Builder(this);
    dia.setTitle(EResources.display_dialog_error);
    dia.setMessage(EResources.display_init_error);
    dia.setCancelable(false);/*  w w w .  ja v  a2s .  c  o m*/
    dia.setPositiveButton(EResources.display_confirm, new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            finish();
            Process.killProcess(Process.myPid());
        }
    });
    dia.create();
    dia.show();
}

From source file:com.chen.emailsync.SyncManager.java

static public synchronized EmailClientConnectionManager getClientConnectionManager(Context context,
        HostAuth hostAuth) {/*w ww  . j a v a  2  s  .co  m*/
    // We'll use a different connection manager for each HostAuth
    EmailClientConnectionManager mgr = null;
    // We don't save managers for validation/autodiscover
    if (hostAuth.mId != HostAuth.NOT_SAVED) {
        mgr = sClientConnectionManagers.get(hostAuth.mId);
    }
    if (mgr == null) {
        // After two tries, kill the process.  Most likely, this will happen in the background
        // The service will restart itself after about 5 seconds
        if (sClientConnectionManagerShutdownCount > MAX_CLIENT_CONNECTION_MANAGER_SHUTDOWNS) {
            alwaysLog("Shutting down process to unblock threads");
            Process.killProcess(Process.myPid());
        }
        HttpParams params = new BasicHttpParams();
        params.setIntParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 25);
        params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, sConnPerRoute);
        boolean ssl = hostAuth.shouldUseSsl();
        int port = hostAuth.mPort;
        mgr = EmailClientConnectionManager.newInstance(context, params, hostAuth);
        log("Creating connection manager for port " + port + ", ssl: " + ssl);
        sClientConnectionManagers.put(hostAuth.mId, mgr);
    }
    // Null is a valid return result if we get an exception
    return mgr;
}

From source file:com.android.exchange.SyncManager.java

static public synchronized ClientConnectionManager getClientConnectionManager() {
    if (sClientConnectionManager == null) {
        // After two tries, kill the process.  Most likely, this will happen in the background
        // The service will restart itself after about 5 seconds
        if (sClientConnectionManagerShutdownCount > MAX_CLIENT_CONNECTION_MANAGER_SHUTDOWNS) {
            alwaysLog("Shutting down process to unblock threads");
            Process.killProcess(Process.myPid());
        }//from ww  w .  j a v  a  2  s.  c  om
        // Create a registry for our three schemes; http and https will use built-in factories
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

        // Use "insecure" socket factory.
        SSLSocketFactory sf = new SSLSocketFactory(SSLUtils.getSSLSocketFactory(true));
        sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        // Register the httpts scheme with our factory
        registry.register(new Scheme("httpts", sf, 443));
        // And create a ccm with our registry
        HttpParams params = new BasicHttpParams();
        params.setIntParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 25);
        params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, sConnPerRoute);
        sClientConnectionManager = new ThreadSafeClientConnManager(params, registry);
    }
    // Null is a valid return result if we get an exception
    return sClientConnectionManager;
}

From source file:com.android.exchange.ExchangeService.java

static public synchronized EmailClientConnectionManager getClientConnectionManager() {
    if (sClientConnectionManager == null) {
        // After two tries, kill the process.  Most likely, this will happen in the background
        // The service will restart itself after about 5 seconds
        if (sClientConnectionManagerShutdownCount > MAX_CLIENT_CONNECTION_MANAGER_SHUTDOWNS) {
            alwaysLog("Shutting down process to unblock threads");
            Process.killProcess(Process.myPid());
        }/*from w  ww.java  2s  .c  o  m*/
        HttpParams params = new BasicHttpParams();
        params.setIntParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 25);
        params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, sConnPerRoute);
        sClientConnectionManager = EmailClientConnectionManager.newInstance(params);
    }
    // Null is a valid return result if we get an exception
    return sClientConnectionManager;
}