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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:46:12+00:00 2026-05-31T05:46:12+00:00

I have added a background service to my application which creates a notificaion when

  • 0

I have added a background service to my application which creates a notificaion when a new item is added to my application. When pressing the notification the user is taken into the application and the intent passes an object which allows the application to select the newly added item.

The application is for both mobile phones and tablets. When running on phones the item is shown in a separate activity, when on a tablet a dual fragment layout is used and the item is shown on the right fragment.

In the main activity onCreate I check the intent and check if a item has been passed through and display it if it has. This is working fine on the phone but on a tablet the right fragment is not visible and hence the item can not be shown.

This is what I call at the end of onCreate (I had tried it in onStart and onResume)

Bundle data = queryIntent.getExtras();
    if  (data!=null){
        Deal deal = data.getParcelable("notificationDeal");
        if (deal!=null){
            onDealSelected(deal);
        }
    }

The method onDealSeletced does the following

public void onDealSelected(Deal deal) {
    if (!mDualFragments){
        Intent showDealDetails = new Intent(getApplicationContext(), DealDetailsActivity.class);
        showDealDetails.putExtra("Deal", deal);
        showDealDetails.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(showDealDetails);
        Log.d("OnDealSelected", "1");
    }
    else{ // must be tablet
        if (dealDetailsFragment == null)
            dealDetailsFragment = (DealDetailsFragment) getFragmentManager().findFragmentByTag("dealDetailsFragment");
        if (!dealDetailsFragment.isVisible()){
            FragmentTransaction transaction = getFragmentManager().beginTransaction();
            transaction.replace(R.id.right_fragment_container, dealDetailsFragment);
            transaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            transaction.commit();
            getFragmentManager().executePendingTransactions(); // ensure it is done before we call update deal!
            Log.d("OnDealSelected", "2");
        }
        if (dealDetailsFragment.isVisible())    {
            dealDetailsFragment.updateDeal(deal);
            Log.d("OnDealSelected", "3");
        }
    }
}

On a smartphone mDualFragments is false and hence it shows the deal in a new activity and works as expected.
When on a tablet it goes into the else, however it never gets into the final if as the fragment is not visible.

When running the application on a tablet it goes into the second if but after it the fragment is still not visible.

The same method is used at other points in the application (when a deal is not passed through in the intent) and has been working as expected.

  • 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-31T05:46:14+00:00Added an answer on May 31, 2026 at 5:46 am

    You can use setArguments(Bundle bundle) to pass data to the fragment before it is attached (before the commit action). This way when the Fragment initializes itself it can call getArguments and parse the bundle. This way you don’t have to worry about the fragment being visible yet, it can create its views when ready. There is a full example in the Fragment Docs

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

Sidebar

Related Questions

I have added a new job in my hudson server which builds the project
I am using a JTabbedPane in my application. I have added two tabs which
in my application I have a background functions which caches data - works fine.
Background : I have a C# Windows Forms application that contains a Windows service
I have added some code which compiles cleanly and have just received this Windows
I have added some settings to my c# application using the configuration editor. There
As per clients requirement, i have added a background music to webpage. I have
I have added a background image to my tableview . But when i pull
I have a UIScrollView added to a UIView. Now i have added a background
I have a html button, and i have added a background image to it

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.