YouTubeIntents
extends Object
java.lang.Object | |
↳ | com.google.android.youtube.player.YouTubeIntents |
Overview
A selection of static methods that create intents which navigate to specific activities within the main YouTube application.
Video and playlist IDs required by methods such as
createPlayVideoIntent(Context, String)
or
createOpenPlaylistIntent(Context, String)
are provided by the YouTube Data API. To learn
more about this API, visit https://developers.google.com/youtube/v3/.
Use the canResolve
methods before sending an intent to make sure that the user's device
has a version of the YouTube application that supports the given intent.
Summary
Public methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Checks if the YouTube application installed on the user's device supports the open channel
intent.
| |||||||||||
Checks if the YouTube application installed on the user's device supports the open playlist
intent.
| |||||||||||
Checks if the YouTube application installed on the user's device supports the play playlist
intent.
| |||||||||||
Checks if the YouTube application installed on the user's device supports the play video
intent.
| |||||||||||
Checks if the YouTube application installed on the user's device supports the
fullscreen and finishOnEnd optional parameters when resolving a play video
intent. | |||||||||||
Checks if the YouTube application installed on the user's device supports the open search
results intent.
| |||||||||||
Checks if the YouTube application installed on the user's device supports the upload video
intent.
| |||||||||||
Checks if the YouTube application installed on the user's device supports the open user intent.
| |||||||||||
Creates an Intent that, when resolved, will open the channel page for the given channel ID
in the YouTube application.
| |||||||||||
Creates an Intent that, when resolved, will open the given playlist in the YouTube
application.
| |||||||||||
Creates an Intent that, when resolved, will start playing the given playlist in the YouTube
application from its first video.
| |||||||||||
Creates an Intent that, when resolved, will start playing the video specified by
videoId , within the YouTube application. | |||||||||||
Creates an Intent that, when resolved, will start playing the video specified by
videoId , within the YouTube application. | |||||||||||
Creates an Intent that, when resolved, will open the search results for the given query
in the YouTube application.
| |||||||||||
Creates an Intent that, when resolved, will open the upload activity in the YouTube
application for the video specified by the
videoUri . | |||||||||||
Creates an Intent that, when resolved, will open the user page for the given user ID
in the YouTube application.
| |||||||||||
Retrieves the version code of the YouTube application installed on the user's device.
| |||||||||||
Retrieves the version name of the YouTube application installed on the user's device.
| |||||||||||
Checks if the YouTube application is installed on the user's device.
|
Inherited methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public methods
public static boolean canResolveChannelIntent (Context context)
Checks if the YouTube application installed on the user's device supports the open channel intent.
Parameters
context | The current Context. |
Returns
true
if the YouTube application installed on the user's device allows external apps to navigate to the Channel page,false
otherwise.
See Also
public static boolean canResolveOpenPlaylistIntent (Context context)
Checks if the YouTube application installed on the user's device supports the open playlist intent.
Parameters
context | The current Context. |
Returns
true
if the YouTube application installed on the user's device allows external apps to navigate to the Playlist page,false
otherwise.
public static boolean canResolvePlayPlaylistIntent (Context context)
Checks if the YouTube application installed on the user's device supports the play playlist intent.
Parameters
context | The current Context. |
Returns
true
if the YouTube application installed on the user's device allows external apps to start playing a playlist,false
otherwise.
public static boolean canResolvePlayVideoIntent (Context context)
Checks if the YouTube application installed on the user's device supports the play video intent.
Parameters
context | The current Context. |
Returns
true
if the YouTube application installed on the user's device allows external apps to play a video in the YouTube application,false
otherwise.
public static boolean canResolvePlayVideoIntentWithOptions (Context context)
Checks if the YouTube application installed on the user's device supports the
fullscreen
and finishOnEnd
optional parameters when resolving a play video
intent.
- If this method returns
true
, then your application can call thecreatePlayVideoIntentWithOptions
method. - If this method returns
false
, then your application should call thecreatePlayVideoIntent
method instead.
Parameters
context | The current Context. |
Returns
true
if the YouTube application installed on the user's device supports thefullscreen
andfinishOnEnd
optional parameters when resolving a play video intent,false
otherwise.
public static boolean canResolveSearchIntent (Context context)
Checks if the YouTube application installed on the user's device supports the open search results intent.
Parameters
context | The current Context. |
Returns
true
if the YouTube application installed on the user's device allows external apps to perform a search,false
otherwise.
See Also
public static boolean canResolveUploadIntent (Context context)
Checks if the YouTube application installed on the user's device supports the upload video intent.
Parameters
context | The current Context. |
Returns
true
if the YouTube application installed on the user's device allows external apps to upload videos to YouTube,false
otherwise.
See Also
public static boolean canResolveUserIntent (Context context)
Checks if the YouTube application installed on the user's device supports the open user intent.
Parameters
context | The current Context. |
Returns
true
if the YouTube application installed on the user's device allows external apps to navigate to the User page,false
otherwise.
See Also
public static Intent createChannelIntent (Context context, String channelId)
Creates an Intent that, when resolved, will open the channel page for the given channel ID in the YouTube application.
Parameters
context | The current Context. |
channelId | The ID of the channel to be displayed, as returned from the YouTube Data API. |
Returns
- An Intent that will open the given channel page in the YouTube app.
See Also
public static Intent createOpenPlaylistIntent (Context context, String playlistId)
Creates an Intent that, when resolved, will open the given playlist in the YouTube application.
Parameters
context | The current Context. |
playlistId | The ID of the playlist to be opened, as returned from the YouTube Data API. |
Returns
- An intent that will open the Playlist page in the YouTube app with the given playlist.
public static Intent createPlayPlaylistIntent (Context context, String playlistId)
Creates an Intent that, when resolved, will start playing the given playlist in the YouTube application from its first video.
Parameters
context | The current Context. |
playlistId | The ID of the playlist to be played, as returned from the YouTube Data API. |
Returns
- An intent that will play the given playlist in the YouTube app.
public static Intent createPlayVideoIntent (Context context, String videoId)
Creates an Intent that, when resolved, will start playing the video specified by
videoId
, within the YouTube application.
Parameters
context | The current Context. |
videoId | The ID of the video to be played, as returned from the YouTube Data API. |
Returns
- An Intent which will start playing the video in the YouTube application.
See Also
public static Intent createPlayVideoIntentWithOptions (Context context, String videoId, boolean fullscreen, boolean finishOnEnd)
Creates an Intent that, when resolved, will start playing the video specified by
videoId
, within the YouTube application.
Parameters
context | The current Context. |
videoId | The ID of the video to be played, as returned from the YouTube Data API. |
fullscreen | If true the video will be played fullscreen, if false the
video will be played according to the orientation of the device. |
finishOnEnd | If true will finish the YouTube application activity and return to
the calling activity once the video has finished, if false will only return
when the user clicks the back button. |
Returns
- An Intent which will start playing the video.
public static Intent createSearchIntent (Context context, String query)
Creates an Intent that, when resolved, will open the search results for the given query in the YouTube application.
Parameters
context | The current Context. |
query | The search query to request search results for. |
Returns
- An Intent that will open the search results page in the YouTube app with the results for the given query.
See Also
public static Intent createUploadIntent (Context context, Uri videoUri)
Creates an Intent that, when resolved, will open the upload activity in the YouTube
application for the video specified by the videoUri
. An exception will be thrown if
videoUri
does not exist or is invalid. If the video specified by videoUri
does
not exist, the resulting Activity will end immediately after starting.
Parameters
context | The current Context. |
videoUri | A Uri that points to the video on your device you wish to upload. |
Returns
- An Intent that will open the upload page in the YouTube app, with the specified video already selected for loaded.
Throws
IllegalArgumentException | will be thrown if the video specified by the Uri is invalid. |
See Also
public static Intent createUserIntent (Context context, String username)
Creates an Intent that, when resolved, will open the user page for the given user ID in the YouTube application.
Parameters
context | The current Context. |
username | The name of the channel that you want to retrieve information about. |
Returns
- An Intent that will open the given users' page in the YouTube app.
See Also
public static int getInstalledYouTubeVersionCode (Context context)
Retrieves the version code of the YouTube application installed on the user's device.
Parameters
context | The current Context. |
Returns
- A string representation of the version of YouTube installed on this device or
-1
if YouTube is not installed.
public static String getInstalledYouTubeVersionName (Context context)
Retrieves the version name of the YouTube application installed on the user's device.
Parameters
context | The current Context. |
Returns
- A string representation of the version of YouTube installed on this device or
null
if YouTube is not installed.
public static boolean isYouTubeInstalled (Context context)
Checks if the YouTube application is installed on the user's device.
Parameters
context | The current Context. |
Returns
true
if the YouTube application is installed on the user's device,false
otherwise.