google-developer-training / android-fundamentals-apps-v2

Other
649 stars 2.63k forks source link

Android Fundamentals codelab: #218

Closed zzzzzwyu closed 1 year ago

zzzzzwyu commented 4 years ago

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 works try{ startActivity(intent); }catch (ActivityNotFoundException e){ Log.d("ImplicitIntents", "Can not handle this!"); }

Versions

  1. What version of Android Studio are you using? 4.1
  2. What API level are you targeting? 17

Additional information Add any other context about the problem here.

codelab: android-fundamentals

zakacat commented 3 years 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?

hhyeok1026 commented 2 years ago

Add the tag to the menifest file.

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>