Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7404123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:12:36+00:00 2026-05-29T05:12:36+00:00

I have a problem with my Android app. I have three Activities that all

  • 0

I have a problem with my Android app. I have three Activities that all connect with one another with a Image button.

My problem is I can’t go back on any of the pages, just forwards. I have been reading about the back button and how to keep its state and not kill (End) it, so the user can click back if needed too.

I am new to Android and I know there’s a lot to learn. So thank you for your help.

Java code for first Activity:

package my.hope;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.content.Intent;
public class NewhopeActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ImageView myImage = (ImageView) findViewById(R.id.imagebutton1);
    myImage.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub          
                Intent intent = new Intent(NewhopeActivity.this, Act2.class);
                startActivity(intent);
            }

});
}

}

XML code:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" android:background="@drawable/mint">


    <ImageButton
    android:id="@+id/imagebutton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="250dp"
    android:background="@drawable/ic_launcher"
    android:onClick="Act2"
    android:src="@drawable/ic_launcher" />

    </LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:12:37+00:00Added an answer on May 29, 2026 at 5:12 am

    What happens when you click the back button on your device? Unless specified, it kills the current activity and brings you back to the previous one.
    However, if you wish to specify exactly what would clicking the back button do, you can override the onBackPressed() method:

    @Override
    public void onBackPressed() {
        Intent intent = new Intent(CurrentActivity.this, NextActivity.class);
        startActivity(intent);
    
        finish();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android app, in which Activities fire long running operations that run
I have three activities that I can call A, B and C. I want
I have an a Java Android app that calls different activities. I thought this
In my Android app, I have some data that needs to be synced daily
I have a library android project Library (with activities and all) and a normal
I have a TabActivity that hosts other three activities. If the first tab is
I have a strange problem with my Android app. When I start it from
I have android app that talks to server and syncs some data int SQLite
I have two different Search activities implemented with SearchManager in my app. One is
I have 3 activities. 1st activity has a 'go right' image button. (to move

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.