Youtube API ActivityNotFoundException on Gingerbread

前端 未结 6 1903
悲&欢浪女
悲&欢浪女 2021-01-12 14:20

I am getting ActivityNotFoundException error when i am trying to run youtube api StandAlonePlayerActivity on ginger bread. Where as it runs fine on ICS

here is my l

6条回答
  •  星月不相逢
    2021-01-12 14:54

    First check if the youtube service is available on your device, then try to launch that activity. YouTubeApiServiceUtil.isYouTubeApiServiceAvailable(mContext). Also try installing the youtube app from Google play.

    Tiny note from the documentation: Note: Users need to run version 4.2.16 of the mobile YouTube app (or higher) to use the API.

    Edit: This is how you use it:

    if(YouTubeApiServiceUtil.isYouTubeApiServiceAvailable(mContext).equals(YouTubeInitializationResult.SUCCESS)){
       //This means that your device has the Youtube API Service (the app) and you are safe to launch it. 
    
    }else{
       // Log the outcome, take necessary measure, like playing the video in webview :)  
    }
    

    See the YouTubeInitializationResult enums here https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubeInitializationResult

    Also the philosophy about the aforementioned class: https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubeApiServiceUtil

提交回复
热议问题