Question

I am having a Tabactivity with two tabs and I am calling this tab activity from other activities ..but I want to set tab according to activity from where tab activity has been called .For that I have used intent flag SINGLE TOP and override onNewIntent() in Tabactivity so that I can find from where Tabactivity has been called and set tab according to that but my onNewIntent() is not getting called ..dont know why ..I have also mentioned launch mode SINGLE TOP ..Here is my Code for intent and onNewINtent(). Is there any other way to do this..

Intent i =new   Intent(Activity1.this,TabViewActivity.class);
i.putExtra("show","mytab");
i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);


    @Override
    protected void onNewIntent(Intent intent) {
        // TODO Auto-generated method stub
        Log.e("new Intent","new intent has came ");
        if(intent.getExtras().getString("show").equalsIgnoreCase("mytab"))
        {
              View tabView = getTabWidget().getChildAt(0);
              tabView.findViewById(R.id.tabSelectedDivider).setVisibility(View.VISIBLE);
              tabHost.setCurrentTab(0);   
        }

        super.onNewIntent(intent);
    }
Was it helpful?

Solution

this.getIntent().getExtras() != null) { 
bundle = this.getIntent().getExtras();
}

can use this also inside oncreate no need for onNewIntent().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top