From the course: Android Development: Understanding Intents
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Intent resolution - Android Tutorial
From the course: Android Development: Understanding Intents
Intent resolution
One of the things that you need to be careful about when working with implicit intents is that the user might not have any apps on their system that can handle the request. Now, if that happens then your call to the start activity function is going to fail and your app will crash, which is obviously not a great experience for the user. So in order to prevent this from happening you need to make sure that there is at least one app that can handle the request and to do this you use a function called Resolve Activity. So let's fix our code in the main activity file to use this function. So I'm going to scroll down to the place where I call start activity for my implicit intent and I'm going to use the Resolve Activity function to ensure that there is at least one app that can handle this intent. So I'm going to write if and then on the intent, I'm going to call Resolve Activity and then that takes, as an argument, the package manager and to get that I'm just going to simply call get…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.