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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:29:19+00:00 2026-05-18T08:29:19+00:00

I have an application with multiple activities. In the main class I open a

  • 0

I have an application with multiple activities. In the main class I open a database and create a list of the content like so:

public class MyApplication extends Activity
{
    private List<PhoneNumber> numberList;

    public void onCreate(Bundle savedInstanceState)
    {
        ...
        numberList = new ArrayList<PhoneNumber>();
        ...
        loadDatabase()
        ...
    }

    private void loadDatabase()
    {
        // File IO and parsing stuff
        addNumber(thisNumber);   // executes for each entry
    }

    public void addNumber(PhoneNumber thisNumber)
    {
        numberList.add(thisNumber);
    }
}

This works fine and I have a ListView in the main activity that is populated with this data. Now, moving on to the next step. I am trying to launch a form as a new activity that will add an entry to this list. The activity launches fine, and I was able to build a form easily. The problem is accessing the list to add to it.

public class AddNumber extends Activity
{
    ...
    // This function is called from the done button
    // <Button android:text="Done" android:onClick="formDone"/>
    public void formDone(View v)
    {
        // findViewByIds here to get data from form. 
        // This is done correctly and I can see my data in memory

        MyApplication access = new MyApplication();
        PhoneNumber newNumber = new PhoneNumber();

        // Fill newNumber object with data from form. Done correctly. Verified

        access.addNumber(newNumber);
    }

The last line of formDone() executes correctly. Through debugging I can step through to the Application class and it executes addNumber(). Before executing numberList.add(thisNumber); I can look at the contents of memory for the thisNumber object it is trying to add to the list and that data is correct. Attempting to execute that line though crashes the application in standard Android format. (Loads View.class with ‘Source not found’ followed by ZygoteInit$MethodBlahBlah).

So I’m a little confused because it looks like the data being fed to addNumber() is correct, and the function works perfectly fine when the application first launches by building the list from the data in the database. Fundamentally, am I thinking about this correct? Should a form like this be it’s own activity or is there a better way to do it? If it can be it’s own activity, what am I doing wrong?

Thanks,
Nate

  • 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-18T08:29:19+00:00Added an answer on May 18, 2026 at 8:29 am

    As Falmarri pointed out, it is not valid to instantiate an Application or Activity class directly.

    Instead, you have two primary options for communicating between Activities.

    1. Pass information via the Intent. Add the phone number list as an extra to the intent that starts AddNumber, and return the altered list when you finish.

    2. Store information in a custom Application. Extend the Application class, (select it as your Application class in the manifest). Store your number list there. You can access the Application class from any Activity via getApplication(). Just cast it to your Application class, and access the method.

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

Sidebar

Related Questions

I have an application with multiple "pick list" entities, such as used to populate
I have an application deployed into multiple zones and there are some issues with
I have an application running on multiple IIS servers that need to parse a
I have an application that has multiple states, with each state responding to input
I have an application that runs transactions spanning over multiple databases on the same
Here at work we have a very large application with multiple sub applications. (500
I have a TreeView control in my WinForms .NET application that has multiple levels
I have multiple threads (C# application running on IIS) running that all need to
I have multiple layers in an application and i find myself having to bubble
I have a networking Linux application which receives RTP streams from multiple destinations, does

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.