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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:37:00+00:00 2026-06-08T17:37:00+00:00

So my application re-uses quite a few activities. Originally I was simply adding a

  • 0

So my application re-uses quite a few activities. Originally I was simply adding a “fromClass” line as an extra to Intents as I switched between activities. The problem now is that I need to know which class I started with several activities ago, in order to display information properly on the current activity. I was trying to use an arraylist of strings to store the order and remove them from the list as I went backwards, but I cannot get strings to translate into class names and work correctly.

At the start of the activity I’m adding the following way:

Global.appNavigation.add("SecondActivity.class")

When I call onBackPressed() I’m doing this:

/* Remove Last Object (this class) */
    Globals.appNavigation
            .remove(Globals.appNavigation.size() - 1);
    try {
        Class<?> c = Class.forName(Globals.applicationNavigation
                .get(Globals.appNavigation.size() - 1));
        Activity obj = (Activity) c.newInstance();
        Intent i = new Intent(mActivity, c);
        startActivity(i);
        finish();
    } catch (ClassNotFoundException e) {
        Log.e("Back", "Could not get a class name");
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

I’m constantly getting the ClassNotFoundException. Is there a better way to do this? This application I’m working with is getting quite large, so not calling finish() to an activity may not work in this case.

  • 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-06-08T17:37:01+00:00Added an answer on June 8, 2026 at 5:37 pm

    I ended up calling the “finish()” method, but did a better job keeping track of data that needed to be persistent.

    Thanks to Ben Von Handorf for the suggestion (see comments 1 and 3 on original question)

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

Sidebar

Related Questions

I am building an application that uses quite a few commands, and they are
This is getting me quite confused: I have a small application that uses a
I've have quite small asp.net MVC 2 application to maintain/extend. Currently it uses hand
Simple problem. I'm working on a Delphi 2007/WIN32 application which now uses MS Access
I am looking at quite a monstrosity of an application that uses several tables
I have a WPF application that uses MVVM data bindings. I am adding items
My application uses quite a lot of pictures that are downloaded from the internet
I've developed a small c# application that uses quite intensive Database calculations. I am
I have an app that uses quite a few graphics in it. When I
I have an application which uses some external library for analytics. Problem is that

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.