List of usage examples for android.os Process myPid
public static final int myPid()
From source file:net.bluecarrot.lite.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.top: {//scroll on the top of the page webViewFacebook.scrollTo(0, 0);//from www . j a va 2 s . c om break; } case R.id.openInBrowser: {//open the actual page into using the browser webViewFacebook.getContext() .startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(webViewFacebook.getUrl()))); break; } case R.id.refresh: {//refresh the page refreshPage(); break; } case R.id.home: {//go to the home goHome(); break; } case R.id.share: {//share this app Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.downloadThisApp)); startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share))); Toast.makeText(getApplicationContext(), getResources().getString(R.string.thanks), Toast.LENGTH_SHORT) .show(); break; } case R.id.settings: {//open settings startActivity(new Intent(this, ShowSettingsActivity.class)); return true; } case R.id.exit: {//open settings android.os.Process.killProcess(Process.myPid()); System.exit(1); return true; } default: break; } return super.onOptionsItemSelected(item); }
From source file:com.chen.emailsync.SyncManager.java
static public synchronized EmailClientConnectionManager getClientConnectionManager(Context context, HostAuth hostAuth) {/* w w w. jav 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 w w 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 w w . j ava 2 s. 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; }
From source file:androidx.media.MediaController2.java
private void sendCommand(String command, Bundle args, ResultReceiver receiver) { if (args == null) { args = new Bundle(); }//ww w . j a v a 2 s.c o m MediaControllerCompat controller; ControllerCompatCallback callback; synchronized (mLock) { controller = mControllerCompat; callback = mControllerCompatCallback; } args.putBinder(ARGUMENT_ICONTROLLER_CALLBACK, callback.getIControllerCallback().asBinder()); args.putString(ARGUMENT_PACKAGE_NAME, mContext.getPackageName()); args.putInt(ARGUMENT_UID, Process.myUid()); args.putInt(ARGUMENT_PID, Process.myPid()); controller.sendCommand(command, args, receiver); }