sending bundle to another activity

前端 未结 6 1140
再見小時候
再見小時候 2021-01-15 03:03

I am trying to send a bundle from one activity to another. When I load the bundle in the recieving activity all the information seems to be null. Here is some code:

6条回答
  •  时光取名叫无心
    2021-01-15 03:47

    Bundle b = new Bundle();
    b = toBundle(app.getHotelList().get(position));
    intent.putExtras(b);
    startActivity(intent);
    
    
    
    
    //In your next activity
    //Create another Bundle object and get the string by name
    
    Bundle bundle = getIntent().getExtras();
    if(bundle!=null){
     String hotelName = bundle.getString("hotelname");
    }
    

提交回复
热议问题