List of usage examples for android.app Activity finish
public void finish()
From source file:com.google.samples.apps.topeka.fragment.SignInFragment.java
private void performSignInWithTransition(View v) { final Activity activity = getActivity(); if (v == null || ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) { // Don't run a transition if the passed view is null CategorySelectionActivity.start(activity, mPlayer); activity.finish(); return;/*from w w w . j a v a2 s.c o m*/ } if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) { activity.getWindow().getSharedElementExitTransition().addListener(new TransitionListenerAdapter() { @Override public void onTransitionEnd(Transition transition) { activity.finish(); } }); final Pair[] pairs = TransitionHelper.createSafeTransitionParticipants(activity, true, new Pair<>(v, activity.getString(R.string.transition_avatar))); @SuppressWarnings("unchecked") ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairs); CategorySelectionActivity.start(activity, mPlayer, activityOptions); } }
From source file:de.damdi.fitness.activity.create_workout.DialogWorkoutOverviewFragment.java
/** * Finishes the Activities ExerciseTypeDetailActivity and * ExerciseTypeListActivity ./*from w ww . j a va2 s.co m*/ */ private void finishActivities(Activity activity) { if (activity instanceof ExerciseTypeDetailActivity) { // finish ExerciseTypeDetailActivity AND // ExerciseTypeListActivity activity.finishActivityFromChild(getActivity(), ExerciseTypeListActivity.RESULT_WORKOUT); activity.finish(); } else { // finish ExerciseTypeListActivity activity.finish(); } }
From source file:com.github.ppamorim.library.DraggerView.java
private void finish() { if (canFinish) { Context context = getContext(); if (context instanceof Activity) { Activity activity = (Activity) context; if (!activity.isFinishing()) { activity.overridePendingTransition(0, android.R.anim.fade_out); activity.finish(); }//from w w w. j a v a 2 s . c o m } } }
From source file:com.ui.UiActivity.java
public void startActivity(Activity activity, Class<?> zls, final Map<String, String> intentParameter) { Intent intent = (Intent) activity.getIntent(); intent.setClass(activity.getBaseContext(), zls); if (null != intentParameter) { for (Map.Entry<String, String> entry : intentParameter.entrySet()) { intent.putExtra(entry.getKey(), entry.getValue()); }/*ww w . j a v a 2s.c om*/ } activity.startActivity(intent); activity.finish(); }
From source file:io.imoji.sdk.editor.fragment.CreateTaskFragment.java
private void notifySuccess(Imoji result, Activity a) { EditorBitmapCache.getInstance().clearNonOutlinedBitmaps(); Intent intent = new Intent(); intent.putExtra(ImojiEditorActivity.IMOJI_MODEL_BUNDLE_ARG_KEY, result); a.setResult(Activity.RESULT_OK, intent); LocalBroadcastManager.getInstance(a) .sendBroadcast(new Intent(ImojiEditorActivity.IMOJI_CREATION_FINISHED_BROADCAST_ACTION)); a.finish(); }
From source file:fr.cph.stock.android.StockTrackerApp.java
/** * This function logout the user and removes its login/password from the preferences. It also loads the login activity * //from ww w .jav a 2s .c o m * @param activity * the activity to finish */ public void logOut(Activity activity) { SharedPreferences settings = getSharedPreferences(BaseActivity.PREFS_NAME, 0); String login = settings.getString("login", null); String password = settings.getString("password", null); if (login != null) { settings.edit().remove("login").commit(); } if (password != null) { settings.edit().remove("password").commit(); } activity.setResult(100); activity.finish(); Intent intent = new Intent(this, LoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
From source file:com.apptentive.android.sdk.module.engagement.interaction.view.survey.SurveyInteractionView.java
@Override public void doOnCreate(final Activity activity, Bundle savedInstanceState) { if (savedInstanceState != null) { surveySubmitted = savedInstanceState.getBoolean(KEY_SURVEY_SUBMITTED, false); }//from w w w.j av a 2 s .c om if (interaction == null || surveySubmitted) { activity.finish(); return; } activity.setContentView(R.layout.apptentive_survey); // Hide branding if needed. final View branding = activity.findViewById(R.id.apptentive_branding_view); if (branding != null) { if (Configuration.load(activity).isHideBranding(activity)) { branding.setVisibility(View.GONE); } } TextView title = (TextView) activity.findViewById(R.id.title); title.setFocusable(true); title.setFocusableInTouchMode(true); title.setText(interaction.getName()); String descriptionText = interaction.getDescription(); if (descriptionText != null) { TextView description = (TextView) activity.findViewById(R.id.description); description.setText(descriptionText); description.setVisibility(View.VISIBLE); } final Button send = (Button) activity.findViewById(R.id.send); send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Util.hideSoftKeyboard(activity, view); surveySubmitted = true; if (interaction.isShowSuccessMessage() && interaction.getSuccessMessage() != null) { SurveyThankYouDialog dialog = new SurveyThankYouDialog(activity); dialog.setMessage(interaction.getSuccessMessage()); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { activity.finish(); } }); dialog.show(); } else { activity.finish(); } EngagementModule.engageInternal(activity, interaction, EVENT_SUBMIT, data.toString()); ApptentiveDatabase.getInstance(activity).addPayload(new SurveyResponse(interaction, surveyState)); Log.d("Survey Submitted."); callListener(true); cleanup(); } }); LinearLayout questions = (LinearLayout) activity.findViewById(R.id.questions); questions.removeAllViews(); // Then render all the questions for (final Question question : interaction.getQuestions()) { if (question.getType() == Question.QUESTION_TYPE_SINGLELINE) { TextSurveyQuestionView textQuestionView = new TextSurveyQuestionView(activity, surveyState, (SinglelineQuestion) question); textQuestionView.setOnSurveyQuestionAnsweredListener(new OnSurveyQuestionAnsweredListener() { public void onAnswered() { sendMetricForQuestion(activity, question); send.setEnabled(isSurveyValid()); } }); questions.addView(textQuestionView); } else if (question.getType() == Question.QUESTION_TYPE_MULTICHOICE) { MultichoiceSurveyQuestionView multichoiceQuestionView = new MultichoiceSurveyQuestionView(activity, surveyState, (MultichoiceQuestion) question); multichoiceQuestionView.setOnSurveyQuestionAnsweredListener(new OnSurveyQuestionAnsweredListener() { public void onAnswered() { sendMetricForQuestion(activity, question); send.setEnabled(isSurveyValid()); } }); questions.addView(multichoiceQuestionView); } else if (question.getType() == Question.QUESTION_TYPE_MULTISELECT) { MultiselectSurveyQuestionView multiselectQuestionView = new MultiselectSurveyQuestionView(activity, surveyState, (MultiselectQuestion) question); multiselectQuestionView.setOnSurveyQuestionAnsweredListener(new OnSurveyQuestionAnsweredListener() { public void onAnswered() { sendMetricForQuestion(activity, question); send.setEnabled(isSurveyValid()); } }); questions.addView(multiselectQuestionView); } } send.setEnabled(isSurveyValid()); // Force the top of the survey to be shown first. title.requestFocus(); }
From source file:cn.bingoogolapple.scaffolding.util.AppManager.java
/** * ? MainActivity ?//ww w . j a v a2s . c o m * * @param activityClass */ public void popOthersActivity(Class<Activity> activityClass) { if (activityClass == null || mActivityStack.isEmpty()) { return; } Iterator<Activity> iterator = mActivityStack.iterator(); while (iterator.hasNext()) { Activity activity = iterator.next(); if (!activity.getClass().equals(activityClass)) { activity.finish(); iterator.remove(); } } }
From source file:com.freecats.demo.swipebackdemo.view.SwipeBackLayout.java
private void finish() { Activity act = (Activity) getContext(); act.finish(); }
From source file:com.cerema.cloud2.ui.preview.PreviewImageFragment.java
/** * Finishes the preview */ private void finish() { Activity container = getActivity(); container.finish(); }