简体   繁体   中英

Pass Object Reference to Intent

I have a gallery app where the user is granted the opportunity to take photos while in an album,can open camera by clicking a button, and the taken photos are automatically added to that album. So, I have an activity called Photos, I use recyclerview in this activity to show the photos in the album. And I have a class called PhotoAdapter and also one activity for camera, namely CamLauncher. CamLauncher is started by an intent created in Photos. When I take a picture and save it, I have to update the dataset the recyclerview uses and that is done by a function in Photos. How can I call the funtion that updates the dataset, which is in Photos.java from CamLauncher.java?

Start your CamLauncher with startActivityForResult . Once the user clicks the photo, set the relevant information your Photos activity needs.

In Photos activity use onActivityResult method to do the necessary updates. Refer to the documentation for more details: https://developer.android.com/training/basics/intents/result.html .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM