Hi everyone.
Android have a very powerful system to extend your application features named Intents (Intent, Pending Intents, Intent Filter, Activities for the ones that do know the inner workings of Android).
With this Intent system you can delegate specific task to other applications in order to keep simple and concise to your specific needs, this way your app:
- Doesnt need to have persmission to access a hardware feature like camera, gps, read contacts etc, long etc.
- Doesnt need to reinvent the wheel creating features that others apps do well, and in most of the times, have gone trough more testing than yours.
- Users after some time get comfortable with the idea of reusing some apps for other apps. This way , if you present them the default camera all time, they will have more skill using that, than learning a need app interaction pattern, even when your approach is the best thing and a total revolution in UI metaphors. humans are beings of habits, so breaking the habit takes time, and usually is because the user want to, not because you want them to do it.
Lets take for example Whatsapp, did they created a brand new camera, no, there are intents taht allow you to launch the default camera and the path were the new video or image should be stored, it can even return you a smal bitmap of the captured image. What camera it will use, any that is available.
This bring another topic, Permissions and Features from the manifest file. The most important difference is that "PERMISSION" mean that the app will use a feature that is protected, a "USE FEATURE" means that the app requires that the hardware actually have the feature available.
Permissions can be revoked, and features can be optional.
Returning to the intent system, I found it very useful when youre creating apps with media interaction, and the creation of lockers/launchers. I haven't created a public fully pledged launcher per se, but have used the feature to create Kiosk apps where only few apps needs to be available.
There are 2 types of intents, Explicit and Implicit.
- Explicit intents needs the package/activity that will be called.
- Implicit do not need package/activity names, but need the action and the category.
Some intents need the data (uri), type (myme type) and extras, not all of them have a meaningful result so its usage depend on case to case basis.
Whenever you work with intents, keep this in mind, if you will use a implicit intent, please check if the package is installed, otherwise your app will crash.
And if you will use implicit intents, the system may rise the Resolve dialog, where you need to define what app will complete the action, until a default is selected for next times.
Custom Android ROMS usually lack of google apps, including Remix OS, and this may be a problem even when you install the play services apk. If you call an implicit intent for a calculator app and there is none, you may get into errors. this i up to the end user and I advise to inform your users of what defaults your capp is capable of calling them, so they will be the ones who need to install the apps in order to make your app fully functional. You can call the market app with a predefined "feature" app that can handle the intent, but the user is the one who decides to install it.
Stock android ROMs do not lack of these default intents apps, but from time to time, their ROMS is a mess and problems may arise.
Keep in mind that currently Onresult only returns the result code of the intent, not the data. Regards.