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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:09:24+00:00 2026-06-10T17:09:24+00:00

I have an app which is basically a launcher with a main activity and

  • 0

I have an app which is basically a launcher with a main activity and view pager fragments and i just noticed that if i launch an app from my app and my app gets killed when i return somehow the on create fragment function get´s called first that my on create main activity function.

This eventually crashes my app because i get a list of all applications using the main activity first and then each pager view fragment will get a sub list from the main list.
The app runs fine when executed for the first time because android runs first the on create of the main activity and then the on create of the fragments

So how can i solve this? is there a way to call first the onCreate Main Activity function? or is there a better way do to this?

The app gives illegal argument exception when i try to create the shorter list, and since the main list is only filled be the main activity when i return to my app the main list is empty giving me the exception

The code:

`

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.grid, null);

        GridView gridview = (GridView) view.findViewById(R.id.gridview);

        int starterPosition;

        starterPosition = 16 * position;
        int enderPosition = starterPosition + 16;

        if (enderPosition > appsList.size()) {
            enderPosition = appsList.size();
        }


        ArrayList<App> shorterList = new ArrayList<App>(appsList.subList(
                starterPosition, enderPosition));

        final AppLauncherAdapter grid = new AppLauncherAdapter(ctx, shorterList);

        gridview.setAdapter(grid);

        gridview.setSelector(R.color.trans);


        return gridview;
    }

`

  • 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-10T17:09:25+00:00Added an answer on June 10, 2026 at 5:09 pm

    There is a method called onActivityCreated that you should use specifically for this purpose. onActivityCreated will always be called after the Activity‘s onCreate method.

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

Sidebar

Related Questions

I'm writing a silverlight app which does some real-time charting. Basically, I just have
I have an iPhone app which is pulling just about all it's data from
I have a Weather app with four Activities. The main/launcher activity is 'invisible' using...
In the main activity of my app, I have three tabs which, when clicked,
I have a django app which basically is just a photo album. Right now
I have a need for a model(?) on my app which basically contains a
I have app in which i have recorded sound files i want that i
I have a app which will download a file from web. The download action
I have an app which is based on the Qt Graphics View framework. It's
I have successfully created a asp mvc app which basically has interface, service and

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.