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 6748617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:35:12+00:00 2026-05-26T12:35:12+00:00

I have two activities. Home activity contain a list view with two buttons named

  • 0

I have two activities.

Home activity contain a list view with two buttons named checkIn and directions.when checkIn button is clicked it does some operation (say A).

When direction button is clicked it launches directions activity.So in directions activity if some condition satisfies there comes an alertbox asking for whether to check In or not.If yes is clicked,I want to do operation A on the checkin button but without destroying directions activity.ie,I want to control the button OnclickListener with the status of an alertbox in other activity without losing the state of present activity.

this is the portion of the code in getView of Listadapter used by Listview of Home activity.btnChild1 is the CheckIn button.

btnChild1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (btnChild1.getText().toString().equals("Check In")) {
                btnChild1.setText("Cancel");
                taskSubList.get(position).setCheckIn(1);
                startTime = System.currentTimeMillis();

            } else {
                btnChild1.setText("Check In");
                taskSubList.get(position).setCheckIn(0);
                long difference =taskSubList.get(position).getTimeSpent() +System.currentTimeMillis() - startTime;
                taskSubList.get(position).setTimeSpent(difference); 
                String values[]={Integer.toString(taskSubList.get(position).getId()), Integer.toString((int) difference)};
                String updateTime=Helper.getfromUrl(updateTimeUrl,values);
                if (!updateTime.equals("success"))
                {
                    Toast.makeText(context, "Not updated", Toast.LENGTH_SHORT).show();
                }
                Intent reasonIn = new Intent(context.getApplicationContext(), Reason.class);
                context.startActivity(reasonIn);
            }

        }
    }); 

And in Directions.java

    if((int)distance/1000 <= 30 && checkInStatus == 0)
    {
        AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
        alertbox.setMessage("Do you want to Check In?");
        alertbox.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                // I have to do the above function
            }
        });
       alertbox.setNegativeButton("No", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface arg0, int arg1) {

            }

        });
        alertbox.show();
    }
  • 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-26T12:35:13+00:00Added an answer on May 26, 2026 at 12:35 pm

    “without destroying directions activity” – Just dont call finish() method and the activity will not be destroyed but will be hold only “onPause”.

    In your situation you need to be more specific what the checkln stuff does. if it somehow changed the UI of the first activity or not for instance.

    If the checkln just display something (image, text, data from web service) just call

    StartActivityForResult(Intent intent, int requestCode);
    

    and then when the time for displaying infromation is fullfied just finish the newly created activity and call

    SetResult(int resultCode);
    

    and you are back to your second activity displaying the same what it was displaying before the alertbox was shown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two activities. The first activity display list of the users with short
I have two activities; Home is my first activity and Settings is my second
I'm new to Android. I have two activities. First activity shows selected contact list
I have two activities. In activity1 , I have list view which is populated
I have two Sharepoint lists: - Assignments - Activities The activities list has a
I have two activities, activity1 is starting activity2. in activity 2 I registered an
I have two activities or screens. The second activity has an AlertDialogBox with radiobuttons
I have two activities one displaying map view and another listview, the main objective
I have two activities: Login and List. When i log-in i display the list.
I have two activities A and B, and from activity A, I click on

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.