How do I get extra data from intent on Android?

后端 未结 16 2269
清歌不尽
清歌不尽 2020-11-21 11:01

How can I send data from one activity (intent) to another?

I use this code to send data:

Intent i=new Intent(context,SendMessage.class);
i.putExtra(\         


        
16条回答
  •  有刺的猬
    2020-11-21 11:53

    If you are trying to get extra data in fragments then you can try using:

    Place data using:

    Bundle args = new Bundle();
    args.putInt(DummySectionFragment.ARG_SECTION_NUMBER);
    

    Get data using:

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    
    
      getArguments().getInt(ARG_SECTION_NUMBER);
      getArguments().getString(ARG_SECTION_STRING);
      getArguments().getBoolean(ARG_SECTION_BOOL);
      getArguments().getChar(ARG_SECTION_CHAR);
      getArguments().getByte(ARG_SECTION_DATA);
    
    }
    

提交回复
热议问题