Activity finish - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Activity finish method.

This code example shows how to use the following methods:finish, startActivity
			}); 
			alertDialogBuilder.setNegativeButton(android.R.string.cancel, new OnClickListener() {
				@Override 
				public void onClick(final DialogInterface pDialog, final int pWhich) {
					if(pCancelIntent != null) {
						pActivity.startActivity(pCancelIntent);
					} 
					pActivity.finish();
				} 
			}) 
			.create().show();
			return true; 
		}else{ 
			return false; 
		} 
	} 
 
	// =========================================================== 
	// Inner and Anonymous Classes 
	// =========================================================== 
9
CodeRank
This code example shows how to use the following methods:finish, startActivity, setClass, makeText
 
    protected void onPostExecute(String message) {
        dialog.hide();
        dialog.cancel();
 
        Toast.makeText(context,message,Toast.LENGTH_LONG).show();
 
		Intent i = new Intent().setClass(context, TabWidget.class);
		context.startActivity(i);
 
        context.finish();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:finish, startActivity
      this.activityClass = activityClass;
      this.name = name;
    } 
 
    public void launch(Activity activity) {
      activity.startActivity(new Intent(activity, activityClass));
      activity.finish();
    } 
  } 
 
  private final LayoutInflater inflater;
 
  public PicassoSampleAdapter(Context context) {
    inflater = LayoutInflater.from(context);
  } 
 
  @Override public int getCount() { 
    return Sample.values().length;
  } 
 
8
CodeRank
This code example shows how to use the following methods:finish, makeText
    } 
     
    @Override 
    protected void onPostExecute(Void unused) {
      if (text!=null) {
        Toast.makeText(host, text, Toast.LENGTH_SHORT).show();
      } 
       
      host.finish();
    } 
  } 
} 
6
CodeRank
This code example shows how to use the following methods:finish, getFilesDir
    } 
 
    public void testCopySampleAttachmentsToSDCARD() throws Throwable { 
        Assert.assertNotNull(mActivity);
 
        File sampleImage1 = new File(mActivity.getFilesDir()
                + "/sample_attachment_image1.jpg"); 
        Assert.assertTrue(sampleImage1.exists());
 
        File sampleImage2 = new File(mActivity.getFilesDir()
                + "/sample_attachment_image2.jpg"); 
        Assert.assertTrue(sampleImage2.exists());
 
        mActivity.finish();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:finish, startActivity
        @Override 
        protected void onPostExecute(Account account) {
            Activity context = TwitterLoginActivity.this;
 
            // Switch to this new account 
            AccountHolder.getInstance(context).setAccount(account);
            Intent i = new Intent().setClass(context, TabWidget.class);
            context.startActivity(i);
 
            context.finish();
        } 
    } 
 
    /** 
     * Class that injects the JavaScript callback when the 2nd auth 
     * page was reached. 
     */ 
    private class MyWebViewClient extends WebViewClient {
 
        @Override 
7
CodeRank
This code example shows how to use the following methods:finish, sleep
        intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(EXTRAS_CAMERA_FACING,
                android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK);
        Activity act = inst.startActivitySync(intent);
        Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
        captureVideos("Back Camera Video Capture\n", inst);
        act.finish();
    } 
 
    @LargeTest 
    public void testFrontVideoCapture() throws Exception { 
        Instrumentation inst = getInstrumentation();
        Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
 
        intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(EXTRAS_CAMERA_FACING,
                android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
        Activity act = inst.startActivitySync(intent);
7
CodeRank
This code example shows how to use the following methods:finish
        String deviceName = device.getDeviceName();
        Log.d(TAG, "ACTION_USB_DEVICE_DETACHED " + deviceName);
 
        // close our activity if the device it is displaying is disconnected 
        if (deviceName.equals(mDeviceName)) {
            mActivity.finish();
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:finish, startActivity, getClass
	public final static int THEME_Grey = 2;
	 
	public static void changeToTheme(Activity activity,int theme)
	{ 
		setsTheme(theme);
		activity.finish();
		activity.startActivity(new Intent(activity,activity.getClass()));
	} 
	 
	public static void onActivityCreateSetTheme(Activity activity)
	{ 
		switch(getsTheme()) 
		{	 
			default: 
			case THEME_DEFAULT:
				activity.setTheme(R.style.Theme_Blue);
				break; 
			case THEME_Grey:
				activity.setTheme(R.style.Theme_Grey);
				break; 
7
CodeRank
This code example shows how to use the following methods:finish, sleep
        intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(EXTRAS_CAMERA_FACING,
                android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK);
        Activity act = inst.startActivitySync(intent);
        Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
        captureImages("Back Camera Image Capture\n", inst);
        act.finish();
    } 
 
    @LargeTest 
    public void testFrontImageCapture() throws Exception { 
        Instrumentation inst = getInstrumentation();
        Intent intent = new Intent();
 
        intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(EXTRAS_CAMERA_FACING,
                android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
        Activity act = inst.startActivitySync(intent);
7
CodeRank

Related Activity finish Questions & Answers:

Other Activity finish Examples

34:	      Toast.makeText(this, "ORIENTATION Sensor not found",
35:	          Toast.LENGTH_LONG).show();
36:	      finish();
37:	    }
38:	  }

Read More

26:	    gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures);
27:	    if (!gestureLib.load()) {
28:	      finish();
29:	    }
30:	    setContentView(gestureOverlayView);

Read More

89:	
90:				// close this activity
91:				finish();
92:			}
93:

Read More

30:	
31:					// close this activity
32:					finish();
33:				}
34:			}, SPLASH_TIME_OUT);

Read More

225:						setResult(100, i);
226:						finish();
227:					} else {
228:						// failed to update product
229:					}
-
290:						setResult(100, i);
291:						finish();
292:					}
293:				} catch (JSONException e) {
294:					e.printStackTrace();

Read More

finish Method Overview
Call this when your activity is done and should be closed.
See Code Examples for other Android Activity Methods: