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

The Archive Base Latest Questions

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

I have searched and not found any clear answers to a problem im having.

  • 0

I have searched and not found any clear answers to a problem im having.

In my application, I have an activity where you answer to a checkpoint, send it and go to the next one. A user should also be able to skip, and jump back to the previous checkpoint.

Let me support my story with a bit of code.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.checkpointform);
    go = (GlobalObject)getApplication();

    _checkPoints = new ArrayList<CheckPoint>();
    _checkPoints.addAll(go.getCheckPoints());

    _currentActiveItemId = getIntent().getIntExtra("checkPointId", 0);
    int count = 0;
    while(count < _checkPoints.size()) {
        if(_currentActiveItemId == _checkPoints.get(count).getPrimaryKey()) {
            _checkPointTitle = _checkPoints.get(count).getCheckPointTitle();
        }
        count++;
    }

    final TextView tvCheckPointTitle = (TextView)findViewById(R.id.txtCheckpoint);
    tvCheckPointTitle.setText(_checkPointTitle);

    this.registerButtonEvents();

    _simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss");

    Log.d(TAG, "On create");
}

This code is not optimized. I want it to work first before I do that so don’t be hard on me for that, but tips are always very welcome.

So what happens here.
A global(applicationwide) object is instantiated.
I get an arraylist and store it in a local arraylist.

I take the extra from the screen that got me here.
I loop trough the list to compare the currentselected item id with primary key, to get the right data to show.

I then register button events like so:

private void registerButtonEvents() {
    ImageButton btnTakePicture = (ImageButton)findViewById(R.id.btnTakePicture);
    btnTakePicture.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            takePictureButton();            
        }         
    });

    Button btnPreviousCheckPoint = (Button)findViewById(R.id.btnPrev);
    btnPreviousCheckPoint.setOnClickListener(new View.OnClickListener() {   
        @Override
        public void onClick(View v) {
            previousCheckPoint();
        }
    });

    Button btnNextCheckPoint = (Button)findViewById(R.id.btnNext);
    btnNextCheckPoint .setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            nextCheckPoint();
        }
    });
}

The methods called in the onclick events don’t do anything yet.
This is where I need help.

What I need is, the current activity to be destroyed, but before that happens, call this activity.. could be something like: Intent intent = new Intent(this, checkPointFormActivity);

And give the next/previous activity the currentselected id + 1 (if the next item is null, ill get the first item in the list.. this is logic ill worry about later)

However I have been unsuccesfull in calling this activity.

So in short:

I need to call the same activity as the current one, with new data. Upon doing that, I want to destroy/finish/delete/un-do the previous activity. (lets say checkpoint 1 is the current activity. I press next, this activity should be refreshed with new data/finished and be recalled with new data passed in the intent in the form of an ID.

I hope I am providing enough information this way.
If anything is unclear. And it would not surprise me. Please let me know so I can edit.

What I tried is

private void nextCheckPoint() {
    int count = 0;
    int listLength = _checkPoints.size();

    while(count < listLength) {
        if(_currentActiveItemId == _checkPoints.get(count).getPrimaryKey()) {
            final Intent intent = new Intent(this, CheckPointFormActivity.class);
            intent.putExtra("checkPointId", _currentActiveItemId + 1);
            startActivity(intent);
        }
    }
}

and also ttried calling finish() after and before startactivity. It results in my app not responding at all.

Thanks alot for even taking the time to read the question. Hope to see an answer or any advice of how to imrpove the flow soon. Thanks.

  • 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-26T00:12:59+00:00Added an answer on May 26, 2026 at 12:12 am

    I may not have understood you correctly, but what’s the reason for re-instantiating the activity to navigate? Why don’t you:

    1. Just refresh your widgets with the information for the new checkpoint when the user navigates?
    2. Or use a ViewFlipper to navigate between the views within the same activity?
    3. Or use the ViewPager to use fragments the user can navigate using gestures?

    EDIT
    You say you do not know how to refresh the widget with new information. This should be fairly easy.

    You have event handlers for the navigation buttons, so you can determine the new checkpoint, the data of which you want to display. Each control in the view that displays checkpoint-specific data must be changed for the new checkpoint.

    For example, the name of the checkpoint could be displayed within a TextView. Then you’d have to update the TextView like:

    TextView checkPointTitle = (TextView)findViewById(R.id.checkPointTitle);
    checkPointTitle.setText(newCheckPointTitle);
    

    You could create a method that takes the ID of the checkpoint (may be the index is a list of objects for the checkpoints or a database ID or whatever) and updates the controls. Then you call this method from your previousCheckPoint and nextCheckPoint methods after determining the ID of the checkpoint to be displayed. Of course, you call this method also when the Activity is displayed for the first time for the first checkpoint.

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

Sidebar

Related Questions

I've searched the iPhone documentation and on google but have not found any information
I have searched but have not found my answer. Disclaimer: I am brand new
I'll start by saying that I have searched SO and not found an answer
I searched everywhere and have not found any site where it says that the
I have searched far and wide on the Internet but have not found anything
Up till now I have searched for hours on end and have not found
I have searched around a bit, and have not really found a professional type
i have searched the web relentlessly for this and have not found anything -
I have searched the forum and have not found an issue similar to this.
I have searched and not found a solution so sorry if this has been

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.