Closed zzzzzwyu closed 1 year ago
I also had the same issue, and I was able to handle it with a try-catch block as well. This issue is also covered here.
https://stackoverflow.com/questions/62535856/intent-resolveactivity-returns-null-in-api-30.
Someone ^here^ mentions that the issue might have to do with permissions and the Package Manager class.
Versions
What version of Android Studio are you using? 4.1.3
What API level are you targeting? 30
May I suggest to anyone that reads this that we should put the lesson, step, and topic all in the title of the issue?
Add the
You can check the cause in the link below. https://stackoverflow.com/questions/62535856/intent-resolveactivity-returns-null-in-api-30
</manifest>
...
<application>
...
</application>
<queries>
<!-- Browser -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
</intent>
</queries>
</manifest>
Describe the problem The resolveActivity of the implicit intent returns null
In which lesson and step of the codelab can this issue be found? Lesson 2.3 Implicit Intents step 2
How to reproduce? the function openWebsite written like described in the lesson
if (intent.resolveActivity(getPackageManager())!=null){ startActivity(intent); }else{ Log.d("ImplicitIntents", "Can not handle this!");
always gives log can not handle this instead of openning the website (I have also the implicit receiver works) but the try catch workstry{ startActivity(intent); }catch (ActivityNotFoundException e){ Log.d("ImplicitIntents", "Can not handle this!"); }
Versions
Additional information Add any other context about the problem here.
codelab: android-fundamentals