Question

I have a Tabbed Activity that I want to pass an intent to. I am trying to pass some parameters and this is not passing the intent. I am setting the current Tab in the onClickListener. My Code is below how do I do that?

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressLint("InlinedApi")
private void displayEvacRouteTable(){
    AsyncClass ac = new AsyncClass(EvacRouteTableActivity.this);
    ac.execute();
    List<String> evacRouteList = new ArrayList<String>(DALController.sharedInstance().getAllRouteNames());
    // get a reference for the TableLayout
    TableLayout ll = (TableLayout) findViewById(R.id.TableLayout01);
    for (String routeName : evacRouteList){
         // create a new TableRow
        TableRow row = new TableRow(this);
        // create a new TextView
        TextView destNameTextView = new TextView(this);


        String evacRouteName = " " + routeName;
        SpannableString evacRouteSpanString = new SpannableString(evacRouteName);
        evacRouteSpanString.setSpan(new UnderlineSpan(), 0, evacRouteName.length(), 0);
        destNameTextView.setText(evacRouteSpanString);
        destNameTextView.setTextColor(Color.BLUE);
        destNameTextView.setTextSize(20);
        destNameTextView.setHeight(55);
        Linkify.addLinks(evacRouteSpanString, Linkify.ALL);
        final Intent i = new Intent(EvacRouteTableActivity.this, MapViewActivity.class);
        Bundle b = new Bundle();
        b.putString("evacObject", routeName);
        i.putExtras(b);


        destNameTextView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                AsyncClass ac = new AsyncClass(EvacRouteTableActivity.this);
                ac.execute();
                @SuppressWarnings("deprecation")
                TabActivity ta = (TabActivity) EvacRouteTableActivity.this.getParent();
                ta.getTabHost().setCurrentTab(4);

            }
        });
        destNameTextView.setBackgroundResource(R.drawable.cell_shape);
        destNameTextView.setLayoutParams(new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));



        row.addView(destNameTextView);

        ll.addView(row,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 
    }   


}

Here is the code that I am trying to use to receive the intent :

    String fuelStopBundle = getIntent().getExtras();
    if (fuelStopBundle != null){
        evacName = fuelStopBundle.getString("evacObject");
Was it helpful?

Solution

this might help you,Instead of passing the string through intent use static variable as,

your passing class

     class EvacRouteTableActivity extends TabActivity{

    public static String routeName="";

    /**** write your code here****/
    /****change the value of routeName string as per your desire****/

    }

your receiving class,

class MapViewActivity extends Activity{

        /**** write your code here****/
       //access routeName string as below
         String recieved_string= EvacRouteTableActivity.routeName;

        }

please let me know if you have any trouble regarding this.

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