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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:31:50+00:00 2026-06-10T21:31:50+00:00

I have used 3 Fragment s in my application. The 3rd one being a

  • 0

I have used 3 Fragments in my application. The 3rd one being a Listfragment. I load twitter feed in the Listfragment in onActvityCreated().

Now the issue is that the ListFragment is created when I move to the 2nd Fragment, which means that it starts to load the twitter feed. Till the time the feed is received in the 3rd Fragment, which takes long in slow connections, my 2nd Fragment becomes unresponsive completely. I cannot click on any icon or swipe to the 1st Fragment. This happens everytime the Fragment is destroyed.

The code is as follows:

@Override
public void onActivityCreated(Bundle savedInstanceState) 
{
    // TODO Auto-generated method stub

    super.onActivityCreated(savedInstanceState);
    Log.d("TwitterFragment", "onActivityCreated++++++");
    try {

        // tw = new TwitterTask();
        // tw.execute(null);


        final ConnectivityManager connection = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);

        if (connection.getNetworkInfo(0).isConnected() || connection.getNetworkInfo(1).isConnected()) {


            AccessToken a = new AccessToken("something", "something");
            Twitter twitter = new TwitterFactory().getInstance();
            twitter.setOAuthConsumer(Values.CONSUMER_KEY, Values.CONSUMER_SECRET);
            twitter.setOAuthAccessToken(a);

            int i = (int) twitter.getId();
            User u = twitter.showUser(i);
            Log.i("twitter", "user name" + u.getName());
            statuses = twitter.getUserTimeline("something");

            listAdapter.notifyDataSetChanged();
            // Populate list with our static array of titles.

            setListAdapter(listAdapter);
            getListView().setCacheColorHint(Color.TRANSPARENT);
            getListView().setDivider(null);
            getListView().setPadding(10, 0, 10, 0);
            setRetainInstance(true);
            getListView().setClickable(false);
        }
    } catch (Exception e) {
        // TODO: handle exception
        Log.i("something", "Failed to get timeline: " + e.getMessage());
    }

}

This is the code for the getView() of the adapter:

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        final tweetViewHolder tweet;
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.twitterfeed_row, null);

            tweet = new tweetViewHolder();
            tweet.twitterText = (TextView) convertView.findViewById(R.id.tweet_text);
            tweet.tweetTime = (TextView) convertView.findViewById(R.id.tweet_time);
            convertView.setTag(tweet);
        } else
            tweet = (tweetViewHolder) convertView.getTag();

        tweet.twitterText.setText(statuses.get(position).getText());
        tweet.tweetTime.setText(statuses.get(position).getCreatedAt().toString());

        return convertView;
    }

    class tweetViewHolder {
        TextView twitterText;
        TextView tweetTime;

        // TextView txtThird;

    }


@Override
    public int getCount() {
        // TODO Auto-generated method stub
        if (statuses == null)
            return 0;
        else
            return statuses.size();

    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        if (statuses != null)
            return statuses.get(position);
        else
            return null;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

Also, I see the default ProgressDialog of the Listfragment in case there is no network.
How can that be controlled? Are there any methods to be overridden for monitoring it?

TIA

  • 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-10T21:31:52+00:00Added an answer on June 10, 2026 at 9:31 pm

    It seems you are doing network connection and data fetch inside the onActivityCreated callback, on the main thread. This blocks the main thread and makes the UI unresponsive. You should load the data from Twitter asynchronously. You should probably use AsyncTaskLoader for this.

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

Sidebar

Related Questions

I have used fragments to define a simple splitview, in the right site i
We have used Shibboleth to authenticate users. It works great. The issue is that
I have used geocoder in my ruby on rails application for a while but
I have a resultset obejct as rs and i used the fragment of code
I have started currently an portfolio application for HoneyComb tablet. I have used ActionBar.Tab
I have used mnesia for a while now. I have to confess that i
When creating an Android application using Loaders, should every activity and fragment have its
I have a very weird issue with fragments. I use the newest support library.
I have a ViewPager within a Fragment in my application. Within the ViewPager I
I have used the silverlight control in CRM 2011.It also published on form but

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.