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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:36:38+00:00 2026-05-30T07:36:38+00:00

I’m trying to pass data from one activity to another via Intent.putExtras like this:

  • 0

I’m trying to pass data from one activity to another via Intent.putExtras like this:

private ArrayList<HashMap<String, String>> mGroups = new ArrayList<HashMap<String, String>>();
private ArrayList<HashMap<String, String>> mUsers = new ArrayList<HashMap<String, String>>();
...

Bundle data = new Bundle();
data.putInt("mode", mode);
data.putSerializable("groups", (Serializable) mGroups);
data.putSerializable("users", (Serializable) mUsers);
data.putInt("current_class", mCurrentClassId);
data.putInt("current_user", mCurrentUserId);

Intent intent = new Intent(ctx, ChildActivity.class);
intent.putExtras(data);
ctx.startActivityForResult(intent, 0);

Here mUsers is a List of HashMap<String,String> with users’ data, including Base64-encoded photo, sum of strings sizes in this list is about 500Kb

Call to startActivityForResult hangs for several minutes with black screen and then I get ANR error. Sub-Activity’s onCreate is not called at all.

If I don’t add large strings into mUsers (no Base64-encoded photos) – works just fine.

Please help.

  • 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-30T07:36:40+00:00Added an answer on May 30, 2026 at 7:36 am

    if both activities are yours, use a decent data model. Android doesn’t encourage that much to very well designed application. Or turn it differently, it allows for fast developped application and doesn’t promote much of good software application principle.

    The solution of @Jean-Philippe Roy (québec ?) is interesting but singleton are quite an anti-pattern when it comes to more elaborate things, namely statefull models or serviceS.

    The best option is to use an application class. This class is your singleton, by nature in android. So,

    • define an application class in your manifest
    • provide a static method to access the unique instance of the application class (it is always a singleton).
    • give it a method to receive and hold your data, call it from your first activity
    • and a second one to get them back in your second activity

    —Updated after @straya’s answer and 18 more month of Android programming 🙂

    The question of sharing a data structure or processes accross application, activities, views, fragments is always present at mind when building Android application. It’s important to know and consider that the application scope is the right place to hold shared structure, but using the application class itself to put a data structure in that scope is not viable with regards to :

    • code quality, if all shared data structures and process are know of the application, it will quickly become bloated with accessors for all those entities.
    • there is only one global shared pool of entities, which is not find grained enough and may lead to hard to detect ways of coupling entities

    I now tend to prefer using Dependency Injection managed singletons. Dagger or RoboGuice both allow to create and inject a single instance of a given class into other classes. This technique, and DI more generally offers great possibilities for good Android designs :

    • don’t degrade quality of code, it is even shortened quite a lot. Use @Inject to inject dependencies and they will get injected.
    • don’t give 2 responsibilities to the singletoned class : it will not handle the singleton instance creation, the framework will do it.
    • it’s easier to pass from a singleton to a normal instance
    • as those singletons become normal classes with a simple annotation, they do not contain static methods anymore and this allows to mock them very easily. And that’s a big point.
    • and of course, DI annotations make it very clear when a class depends on another class, helping to self document code more.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string

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.