List of usage examples for android.app Activity finish
public void finish()
From source file:org.sufficientlysecure.keychain.ui.CreateYubiKeyImportFragment.java
@Override public void onQueuedOperationSuccess(ImportKeyResult result) { long[] masterKeyIds = result.getImportedMasterKeyIds(); if (masterKeyIds.length == 0) { super.onCryptoOperationError(result); return;//from www . j a v a2 s .co m } // null-protected from Queueing*Fragment Activity activity = getActivity(); Intent intent = new Intent(activity, ViewKeyActivity.class); // use the imported masterKeyId, not the one from the yubikey, because // that one might* just have been a subkey of the imported key intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyIds[0])); intent.putExtra(ViewKeyActivity.EXTRA_DISPLAY_RESULT, result); intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, mNfcAid); intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, mNfcUserId); intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, mNfcFingerprints); startActivity(intent); activity.finish(); }
From source file:com.example.android.apprestrictionenforcer.SetupProfileFragment.java
/** * Initiates the managed profile provisioning. If we already have a managed profile set up on * this device, we will get an error dialog in the following provisioning phase. *///from www. j ava2 s. co m private void provisionManagedProfile() { Activity activity = getActivity(); if (null == activity) { return; } Intent intent = new Intent(ACTION_PROVISION_MANAGED_PROFILE); if (Build.VERSION.SDK_INT >= 24) { intent.putExtra(EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME, EnforcerDeviceAdminReceiver.getComponentName(activity)); } else { intent.putExtra(EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME, activity.getApplicationContext().getPackageName()); intent.putExtra(EXTRA_DEVICE_ADMIN, EnforcerDeviceAdminReceiver.getComponentName(activity)); } if (intent.resolveActivity(activity.getPackageManager()) != null) { startActivityForResult(intent, REQUEST_PROVISION_MANAGED_PROFILE); activity.finish(); } else { Toast.makeText(activity, "Device provisioning is not enabled. Stopping.", Toast.LENGTH_SHORT).show(); } }
From source file:im.vector.activity.CommonActivityUtils.java
/** * Logout the current user.//from w w w . ja va 2 s.c om * @param activity the caller activity */ public static void logout(Activity activity) { stopEventStream(activity); try { ShortcutBadger.setBadge(activity, 0); } catch (Exception e) { } // warn that the user logs out Collection<MXSession> sessions = Matrix.getMXSessions(activity); for (MXSession session : sessions) { // Publish to the server that we're now offline MyPresenceManager.getInstance(activity, session).advertiseOffline(); MyPresenceManager.remove(session); } // clear the preferences PreferenceManager.getDefaultSharedPreferences(activity).edit().clear().commit(); // clear credentials Matrix.getInstance(activity).clearSessions(activity, true); // reset the GCM Matrix.getInstance(activity).getSharedGcmRegistrationManager().reset(); // reset the contacts PIDsRetriever.getIntance().reset(); ContactsManager.reset(); MXMediasCache.clearThumbnailsCache(activity); // go to login page activity.startActivity(new Intent(activity, LoginActivity.class)); activity.finish(); }
From source file:org.deviceconnect.android.deviceplugin.theta.fragment.ThetaVRModeFragment.java
private void showReconnectionDialog() { final Activity activity = getActivity(); if (activity != null) { ThetaDialogFragment.showReconnectionDialog(activity, new DialogInterface.OnClickListener() { @Override//from ww w .jav a 2s. c o m public void onClick(final DialogInterface dialog, final int i) { dialog.dismiss(); activity.finish(); showSettingsActivity(); } }, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int i) { dialog.dismiss(); activity.finish(); } }); } }
From source file:com.laquysoft.droidconnl.ScreenSlidePagerActivity.java
@Override public void onSignInSucceeded() { Log.e("AndroidHunt", "Connection succeeded."); mHandler = new Handler(); final Activity bind = this; // If you log in on one activity but switch out before the popup appears, // the popup is just lost. So, we hang around for a few seconds because // we're giving time for the Play Games services login dialog to appear. mHandler.postDelayed(new Runnable() { @Override//from w w w. ja v a2 s. co m public void run() { Intent newIntent = new Intent(bind, ClueActivity.class); startActivity(newIntent); Hunt hunt = Hunt.getHunt(getResources(), getApplicationContext()); hunt.setIntroSeen(true); hunt.save(getResources(), getApplicationContext()); bind.finish(); } }, WAIT_TIME); return; }
From source file:com.granita.tasks.EditTaskFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { final int menuId = item.getItemId(); Activity activity = getActivity(); if (menuId == R.id.editor_action_save) { saveAndExit();/* w w w .j av a 2s . c om*/ return true; } else if (menuId == R.id.editor_action_cancel) { activity.setResult(Activity.RESULT_CANCELED); activity.finish(); return true; } return false; }
From source file:net.clcworld.thermometer.setuppager.Page03Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.page_03, null); final EditText id = (EditText) root.findViewById(R.id.patientId); final Activity parent = this.getActivity(); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(parent); id.setText(prefs.getString("ID", "")); Button okButton = (Button) root.findViewById(R.id.ok); okButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Editor editor = prefs.edit(); String patientId = id.getText().toString(); if (patientId.length() > 0) { editor.putString("ID", patientId); editor.putBoolean("ISFIRSTRUN", false); editor.commit();/*from ww w . ja v a 2 s . c o m*/ AlarmScheduler.setupOneTimeAlarm(parent, System.currentTimeMillis() + 100); Toast.makeText(parent, R.string.patientidsaved, Toast.LENGTH_LONG).show(); parent.finish(); } } }); return root; }
From source file:com.fastbootmobile.encore.app.fragments.PlaylistViewFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new PlaylistViewHandler(this); Bundle args = getArguments();// w ww . j a va 2s.c o m if (args == null) { throw new IllegalArgumentException("This fragment must have a valid playlist"); } // Get the playlist from the arguments, from the instantiation, and from the cache final String playlistRef = args.getString(KEY_PLAYLIST); if (AutoPlaylistHelper.REF_SPECIAL_FAVORITES.equals(playlistRef)) { mPlaylist = AutoPlaylistHelper.getFavoritesPlaylist(getActivity()); mIsSpecialPlaylist = true; } else if (AutoPlaylistHelper.REF_SPECIAL_MOST_PLAYED.equals(playlistRef)) { mPlaylist = AutoPlaylistHelper.getMostPlayedPlaylist(getActivity()); mIsSpecialPlaylist = true; } else { final ProviderAggregator aggregator = ProviderAggregator.getDefault(); mPlaylist = aggregator.retrievePlaylist(playlistRef, null); mIsSpecialPlaylist = false; } if (mPlaylist == null) { Log.e(TAG, "Playlist is null (not in cache, aborting)"); // TODO: Wait for playlist to be loaded, eventually Activity act = getActivity(); if (act != null) { act.finish(); } } }
From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.AddEditFavouriteStopFragment.java
/** * {@inheritDoc}//from w w w. jav a2 s . c om */ @Override public void onClick(final View v) { final Activity activity = getActivity(); if (v == btnOkay) { final String s = edit.getText().toString().trim(); // The stop name is an empty string. Alert the user that this is // not allowed. if (s.length() == 0) { Toast.makeText(activity, R.string.addeditstop_error_blankstopname, Toast.LENGTH_LONG).show(); return; } // Whether we add or edit depends on whether the favourite stop // already exists. if (editing) { sd.modifyFavouriteStop(stopCode, s); } else { sd.insertFavouriteStop(stopCode, s); } } // For both confirming and cancelling, the Activity needs to finish. activity.finish(); }
From source file:org.deviceconnect.android.deviceplugin.theta.fragment.ThetaShootingFragment.java
@Override public void onDisconnected(ThetaDevice device) { mDevice = null;/*from w w w .j a v a 2 s . co m*/ final Activity activity = getActivity(); if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { activity.finish(); } }); } }