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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:29:34+00:00 2026-06-13T08:29:34+00:00

I am using a Tab based Activity in my App and I want to

  • 0

I am using a Tab based Activity in my App and I want to implement a Fragment Stack with WebViews. In these WebViews I want to catch URL requests and replace the current WebView Fragment with a new one. Unfortunately I always get Activity was destroyed Exception but don’t know why.

Can you please give me some hints how to fix this?

I use the following code (At the end of the code sample you will recognise the method handleUrlRequest where I want to replace the current Fragment):

public class FragmentStackSupport extends SherlockFragmentActivity {
int mStackLevel = 1;

public static int THEME = R.style.Theme_Sherlock_Light;

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(THEME); //Used for theme switching in samples
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_stack);


    if (savedInstanceState == null) {
        // Do first time initialization -- add initial fragment.
        Fragment newFragment = Web.newInstance(mStackLevel);
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(R.id.simple_fragment, newFragment).commit();
    } else {
        mStackLevel = savedInstanceState.getInt("level");
    }
}

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putInt("level", mStackLevel);
}


public void addFragmentToStack() {
    mStackLevel++;

    // Instantiate a new fragment.
    Fragment newFragment = Web.newInstance(mStackLevel);

    // Add the fragment to the activity, pushing this transaction
    // on to the back stack.
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.simple_fragment, newFragment);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.addToBackStack(null);
    ft.commit();
}



public static class Web extends SherlockFragment {
    int mNum;

    /**
     * Create a new instance of CountingFragment, providing "num"
     * as an argument.
     */
    static Web newInstance(int num) {
        Web f = new Web();

        // Supply num input as an argument.
        Bundle args = new Bundle();
        args.putInt("num", num);
        f.setArguments(args);

        return f;
    }

    /**
     * When creating, retrieve this instance's number from its arguments.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mNum = getArguments() != null ? getArguments().getInt("num") : 1;
    }

    /**
     * The Fragment's UI is just a simple text view showing its
     * instance number.
     */
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.hello_world, container, false);
        View wv = v.findViewById(R.id.webview);
        WebView webView = ((WebView)wv);

        webView.loadUrl("http://www.google.at");
        webView.setWebViewClient(new MyWebViewClient());



        return v;
    }
}

public static class MyWebViewClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String urlString) {

        handleURLRequest("modal");
        return false;
    }


    private void handleURLRequest(String transitionStyle){

        // here I want to replace the Fragment with a new one.

    }
}

}
  • 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-13T08:29:35+00:00Added an answer on June 13, 2026 at 8:29 am

    Finally I got it. I passed the instance of Web through my WebViewClient where I handle the URL Request and want to do the Fragment Transaction.

    There I call instanceOfWeb.getActivity().getSupportFragmentManager().beginTransaction() to init the Fragment Transaction.

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

Sidebar

Related Questions

i am using tab bar control in my app and want to use the
Okay, I am using a custom tab bar (not a tab based app) but
I want to create a tab using child tab having intents, so that when
I want to pass data from second tab to first tab using delegates.But delegate
I'm trying to launch a website url in a new tab using python in
I have a view based app (not navigation or tab based...) My main view
I want to create a Tableview in a Tab bar application. Because I'm using
I have created a tab based app, in one of the tab, there is
I have developed a tab-based application using API level 7. It is running fine
I'm adding css-based tab navigation to a site that is still using table-based layout.

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.