0

I am building an Android library that is packaged up in an AAR and distributed. The library does camera and image processing work. This type of work often results in memory pressure for the application that consumes the library. The consumer of the library sets up callbacks to handle responses from the library. The interface of the library takes the callbacks and starts the libraries activity by calling startActivity(intent). I have seen memory pressure cause the activity, that the library was called from, to be destroyed. The calling activity being destroyed causes the application to be unpredictable when the library returns. Image of Current Library Setup Flow

I have looked into the new Activity Result APIs (registerForActivityResult()). I could see how creating a custom contract would fix some of the problems I am seeing, since the system will guarantee reconstruction of the activity.

Is it possible to put this in the interface of my library to keep the requirements on the user of the library similar to what they are now? Should I cut out the middle interface layer and have consumers of the library create Custom contracts to use with my libraries main activity? Is there possibly another, better solution?

0 Answers0