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

  • Home
  • SEARCH
  • 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 7065557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:58:15+00:00 2026-05-28T04:58:15+00:00

I have a main activity with a number of buttons. Each button is starting

  • 0

I have a main activity with a number of buttons. Each button is starting another activity.
One of these activities (called MyPuzzlesActivitiy) has a member which has to be loaded from an internet server in order to work. (This member is a list of puzzles to be loaded from the internet)
This member’s right place is the activity.
Even so, I would like to load it before the user actually press the button which starts the activity, to save the time (of waiting to the response from internet server).

I thought about making this member static and start it from the main activity, but it seems a little ugly to me.
Does someone have a better idea to solve this issue?

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-28T04:58:16+00:00Added an answer on May 28, 2026 at 4:58 am

    You’re correct, static is ugly in this case.

    You can store it in the Application: first, you need to subclass Application with a custom class you design (class MyApplication extends Application), then declare it in the manifest (application name="...package...MyApplication").

    Then you can use it from any activity to store data, and retrieve it when you want. As long as your app is active, your data will be available. So you can load the list of your puzzles from your main activity, store it in the application (just add a setter and getter in MyApplication for the type of data you want to store), and retrieve it from the onCreate of your other activity.

    public class MyApplication extends Application {
        private List<Puzzle> puzzles;
    
        public void setPuzzlesList(List<Puzzle> puzzles) {
            this.puzzles = puzzles;
        }
    
        public List<Puzzle> getPuzzlesList() {
            return puzzles;
        }
    }
    

    And from your main activity:

    ((MyApplication) getApplication).setPuzzlesList(..load your list of puzzles from your service...);
    

    and in MyPuzzlesActivity:

    final List<Puzzle> puzzles = ((MyApplication) getApplication).getPuzzlesList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main menu activity with a bunch of buttons. One button starts
I have a lot of buttons on main activity. Each button run this same
At present I have a main Activity which has a number of buttons leading
I have a design of activities like this I have one main activity and
i have main activity in which i have Four menus. and i have one
I have two relatively simple codes. One main activity and one intent service. Main
i have two sub activities apart from main activity. The sequence of calls go
I have an Android App with a number of activities. The wrong activity is
I have one main Activity with layout wrapped into ScrollView like this: <ScrollView android:layout_height=wrap_content
I am creating an app which divides one number by another number. I have

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.