I am developing an android application and I am trying to send an array to another intent. I want to show them in a listview.
How i can achive that?
I have 2 problems.
How to send them to be able later to show them
How to show datas via listview.
On the first activity, when I log out the data its okay.
On the second activity, when i log out the received data, i got null. When I run the app, force close.
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
First activity:
List<String> myList = new ArrayList<String>(Arrays.asList(selectImages));
Intent intent = new Intent(Gallery.this,Upload.class);
intent.putExtra("mylist", selectImages);
startActivity(intent);
Second activity:
public class Upload extends AppCompatActivity {
ListView listView;
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_upload);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
listView = (ListView) findViewById(R.id.list);
Intent i = getIntent();
ArrayList<String> list = i.getStringArrayListExtra("mylist");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, android.R.id.text1, list);
listView.setAdapter(adapter);
Log.i("data","UPLOAD:"+list);
}}