0

facing a problem with TabActivity, I have 5 tabs in may tabActivity to one tab i am playing the YouTube Video using Intent wiht ACTION_VIEW. When i select that tab first time its open the browser and play my Video but next time its not response me. I Try a lot. If you have any solution please share with me.

this is code form TabActivit

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        getWindow().setWindowAnimations(0);

        tabHost = getTabHost();
        tabHost.setup();

        extras = getIntent().getExtras();

        int isFetched = extras.getInt("IsFetched", 0);

        Resources res = getResources();

        Intent t0 = new Intent(this, HomeTabGroup.class);
        t0.putExtra("IsFetched",isFetched);

        tabHost.addTab(tabHost.newTabSpec("Home")
                .setIndicator(prepareTabView(this, "0",  res
                        .getDrawable(R.drawable.hometab)))
                .setContent(t0));

        tabHost.getTabWidget().setBackgroundResource(R.drawable.bg_nav);
       // Intent t1 = new Intent(this, SurprizeMeTabGroup.class);
        Intent t1 = new Intent(this, SurpriseScreen.class);
        tabHost.addTab(tabHost.newTabSpec("surprise")
                .setIndicator(prepareTabView(this, "1",  res
                        .getDrawable(R.drawable.surprizetab)))
                .setContent(t1));




        tabHost.setCurrentTab(0);

        HomeTabGroup.group.tabHost = this.tabHost;

Following is the Code of my SurpizeScreen

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.surprise_screen);
        Intent intent = getYouTubeIntent(this, "http://www.youtube.com/watch?v=6KKXVbJCKEo");
        startActivity(intent);


 }

1 Answers1

0

Finlay after many tries i find the solution. Overwrite the onchange method of class Extended by TabActivity and call the ACTION_VIEW Intent

    @Override
            public void onTabChanged(String tabId) {
                if(tabId.equals("surprise")) {
                    startActivity(getYouTubeIntent(MainTabbarScreen.this, "http://www.youtube.com/watch?v=6KKXVbJCKEo"));
                }
             }
        });