Office Hours Transcript: 2021-12-16
Hello professor, good night =)
how can I help you today?
I’m facing a pretty daunting challenge. I took a job to build an Android SDK to make the use of Camera and integrate with a 3rd party API. There is plenty of material on how to make an app out there but there isn’t much material on how to make a library. So, the question I’m facing the most is, what is the best strategy to use so others developers can make better use of my library? Mainly, how can others communicate with my library? Should I have my own activity and the app that makes use of my library will start my activity (which basically is a custom UI for the camera)?
Currently, my library has one activity and one fragment. When you call my activity you open the camera with a custom UI. I will then capture frame by frame and send it to the API until it responses it got all the data it needs.
Should I have my own activity and the app that makes use of my library will start my activity (which basically is a custom UI for the camera)?
I did that with CWAC-Cam2 (my second attempt at a camera library)
it is easy for developers to integrate, but it is fairly inflexible for them to customize
But I was thinking another way to implement this is to have only the fragment and a navigation. But I lost control of not having my own activity, right?
to have only the fragment and a navigation
I am uncertain what you mean by "a navigation" in this context. If you try forcing consumers of your library to use something like Jetpack Navigation, that may be a barrier to adoption.
But I lost control of not having my own activity
You definitely have more control if you have a full activity. However, you need to weigh that with what the developers integrating your library will want to do.
If the developers using your library are comfortable with your SDK "calling the shots" as to what the UI looks like, the activity approach may be fine.
Yep, I’m mean Jetpack Nav. I thought about this barrier as well.
If, on the other hand, the developers using your library are going to want to have more control over the look and feel, then something smaller (fragment, custom view, etc.) may be more appropriate.
Is CWAC-Cam2 open source?
Sorry, but I think I closed that repo a while back.
You could also offer multiple options: a full activity for "plug and play" usage, which itself is based on something smaller that you also make available in the SDK. This is more work, of course.
"easy for developers to integrate, but it is fairly inflexible for them to customize". It seems a good trade-off to me. Actually, I’m building the custom UI for the camera with all the components needed and I’m expecting the user of the SDK to call my activity with configs which will modify the UI visibility with GONE
I think I found forks of you CWAC-Cam2. I will look into it to have ideas =)
oh, yeah, I am not surprised that some are floating around out there
Do you remember which version was the last one? I will try to find the most up to date one =)
"The Busy Coder’s Guide to Android Development contains three chapters related to this library. One is a tutorial for implementing Android 6.0 runtime permissions that happens to use this library. Another is a chapter on various ways to take pictures that includes coverage of this library. A third chapter explores the camera APIs in Android and references implementation details from this library"
Haha, much of this still applies today?
well, the library itself has not been updated in 5 years
so, like the book you cited, it is not exactly up to date with modern development practices
But the core idea could be applied, right?
if you wanted, sure
Ok, I found this fork on 0.6.9, I will try to take the idea of how to build an SDK