How to Stop,Close or Finish an Activity on Android Java Programmatically

To close,stop or finish an activity, use this java code

// close this activity

For example:

Intent i = new Intent(ThisActivity.this, NextActivity.class);
                // close this activity

This code here opens a new activity (NextActivity.class), then closes the Current Activity (ThisActivity.this). the code “finish();” does this.

Related Posts

Add Admob ads in recyclerview in android

How to add admob native ads to recyclerview in android java Adding admob native ads into android recyclerview isn’t easy like other admob ads. You will need…

Download WebView Flutter Source Code for Android and iOS

Easily create android and iOS WebView app for your websites, the much-awaited flutter WebView source code is here. Are you looking for a flutter WebView source code…

Fix uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:_flutter_android]

This error can be fixed by modifying build.gradle file in the flutter In android studio: go to android>app>build.gradle and modify it as follows:

Get Your Own Android Mobile App for Your Website Today

Are you looking to expand your online presence and reach more customers? In today’s digital age, having a mobile app is an essential tool to connect with…

Don’t Panic: What to Do If Your Phone Won’t Turn On

Don’t Panic: What to Do If Your Phone Won’t Turn On If your phone won’t switch on, it might be the greatest nightmare. Because a phone is…

Why making an app for your website can help your business to grow

In today’s digital age, it’s more important than ever to have a strong online presence. Whether you’re running a business, a blog, or a personal website, having…

This Post Has 3 Comments

  1. @Override
    public void onBackPressed() {
    startActivity(new Intent(this, MainActivity.class));
    next activity is start butt current activity not close

Leave a Reply

Your email address will not be published. Required fields are marked *