Launching Android Netflix App And Passing Video Id - android

In the app I am working on I want to support Netfilx streaming. I intend on doing this by simply starting Netflix and passing a specific URI so it plays a specific video when started. Simple right? Well, the issue is I'm not sure how to pass the video id info in the Intent I use to start the Activity.
I've read the post here , but am unsure where to use this. I used Intent.setData() since it accepts a URI, but to no avail.
Here is what I have been doing (I am hard coding the movie data, this is just for testing purposes) :
// the Netflix intent
Intent intent = getPackageManager().getLaunchIntentForPackage("com.netflix.mediaclient");
//the uri
Uri uri = Uri.parse("http://movies.netflix.com/WiPlayer?movieid=70266228&trkid=13462049&ctx=0%2C1%2Ce2bd7b74-6743-4d5e-864f-1cc2568ba0da-61921755");
intent.setData(uri);
//launches but does not go to the video
startActivity(intent);
I've also tried using the URI protocol in the link above like so:
Uri uri = Uri.parse("nflx://movies.netflix.com/WiPlayer?movieid=70266228&trkid=13462049&ctx=0%2C1%2Ce2bd7b74-6743-4d5e-864f-1cc2568ba0da-61921755");
but still am not seeing the video play.
I feel like I am missing something simple here, although I have had very little luck Googling for this, I could find next to nothing about starting the Netflix Android app from another application. The Netflix developer resources don't have any info on this.
Does anyone have any suggestions on how I can do this or where I should be looking for documentation on this? Any help would be appreciated. Thanks much!

Just some Android Apps intent names to help anyone.
Format: appName, packageName, className
Skype: com.skype.raider, com.skype.raider.Main
Netflix: com.netflix.mediaclient, com.netflix.mediaclient.ui.launch.UIWebViewActivity
ESexplorer: com.estrongs.android.pop, com.estrongs.android.pop.view.FileExplorerActivity
Youtube: com.google.android.youtube,com.google.android.youtube.HomeActivity
Chrome: com.android.chrome,com.google.android.apps.chrome.Main
VLC: org.videolan.vlc, org.videolan.vlc.gui.MainActivity
MBOXSettings: com.mbx.settingsmbox, com.mbx.settingsmbox.SettingsMboxActivity

I've managed to do this. With the following code. First you need the movieId (or videoId) for netflix, then compose the URL to watch.
String netFlixId = "43598743"; // <== isn't a real movie id
String watchUrl = "http://www.netflix.com/watch/"+netFlixId;
Then with this intent
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.netflix.mediaclient", "com.netflix.mediaclient.ui.launch.UIWebViewActivity");
intent.setData(Uri.parse(watchUrl));
startActivity(intent);
}
catch(Exception e)
{
// netflix app isn't installed, send to website.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(item.url));
startActivity(intent);
}
I haven't tried with TV Shows yet. But this works beautifully. If you want to send to the profile page of the movie.. Send it to a url formatted this way
http://www.netflix.com/title/324982
I also found out how to search for a title.
try {
Intent intent = new Intent(Intent.ACTION_SEARCH);
intent.setClassName("com.netflix.mediaclient", "com.netflix.mediaclient.ui.search.SearchActivity");
intent.putExtra("query", item.label);
startActivity(intent);
}
catch(Exception e)
{
Toast.makeText(this, "Please install the NetFlix App!", Toast.LENGTH_SHORT).show();
}

Here is how to start a movie from an ADB command for com.netflix.mediaclient
adb shell am start -n com.netflix.mediaclient/.ui.launch.UIWebViewActivity -a android.intent.action.VIEW -d http://www.netflix.com/watch/60000724
I still can't find a way to do it for com.netflix.ninja (Netflix for Android TV)

Related

How to open both WhatsApp and GB-Whatsapp using an Intent in your Android App

I want to open chooser for both whatsapp and gb-whatsapp so the user can choose any of one from them. This code is only opening whatsapp only.
Intent intentWhatsapp = new Intent(Intent.ACTION_VIEW);
String url = "https://chat.whatsapp.com/JPJSkaiqmDu5gLKqUPAfMM";
intentWhatsapp.setData(Uri.parse(url));
intentWhatsapp.setPackage("com.whatsapp");
startActivity(intentWhatsapp);
To handle business whatsapp, GB-Whatsapp and normal whatsapp, the url scheme intent needs to be used, since the normal method of using package "com.whatsapp" only works for normal whatsapp.
Here's the code sample to handle gb, normal and business whatsapp :
try {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("whatsapp://send?phone="+ "+92300xxxxxxx" +"&text=" + URLEncoder.encode("Message\n", "UTF-8")));
context.startActivity(i);
} catch (Exception e){
Toast.makeText(context, "Whatsapp not installed!", Toast.LENGTH_LONG).show();
}
Simple answer you can't.
More detailed answer: You can only create an Intent targeting one specific app. I would suggest building a dialogue inside your app, showing the app images of whatsapp and gb-whatsapp, and then putting specific intents behind those two images so that it "looks" like the Android chooser.

How to automatically play Playlist in Spotify Android app

I'm trying to play a known playlist in the Spotify app. The best I've got is to load the playlist, but not play it.
Two things I've tried. Firstly to play from search:
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.setComponent(new ComponentName("com.spotify.music",
"com.spotify.music.MainActivity"));
intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS,
MediaStore.Audio.Playlists.ENTRY_CONTENT_TYPE);
intent.putExtra(MediaStore.EXTRA_MEDIA_PLAYLIST, <PLAYLIST>);
intent.putExtra(SearchManager.QUERY, <PLAYLIST>);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
I've tried replacing PLAYLIST with the name of a known playlist. Also tried things like "4Rj0zQ0Ux47upeqVSIuBx9", "spotify:user:11158272501:playlist:4Rj0zQ0Ux47upeqVSIuBx9" etc. All these do is a failed search for these strings.
Second attempt is the View intent:
String uri = "https://play.spotify.com/user/11158272501/playlist/4Rj0zQ0Ux47upeqVSIuBx9";
Intent intent= new Intent( Intent.ACTION_VIEW, Uri.parse(uri) );
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
This loads the playlist, but does not play. If I then use one of the many ways to send a KEYCODE_MEDIA_PLAY key, it just resumes the currently playing list, not this newly loaded list.
Any help from anyone (including Spotify devs)?
BTW I don't want to use the Spotify SDK to implement my own Spotify Player - it seems a shame to have to do this when a perfectly good player is already installed on a user's device.
I found the answer from this blog. What I was missing was the playlist URI as a data Uri in the intent. So not using the proper Android way of Play from search.
So, using the first method from the question, you end up with this:
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.setData(Uri.parse(
"spotify:user:11158272501:playlist:4Rj0zQ0Ux47upeqVSIuBx9"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
3 things to note:
the Uri can't be the https://play.spotify... but has to be the colon seperated type.
the Spotify account must be premium, otherwise the playlist opens but does not play.
this does not work if the screen is off, or lock screen is showing. The spotify activity needs to display on the screen before it loads and plays!
This final point means it isn't actually usable for me... so not accepting answer yet.
Just add :play to Spotify Intent URI
spotify:album:3avifwTCXoRzRxxGM1O0eN:play

Android how to play video using VLC Player?

I have app for play video in android like as
https://play.google.com/store/apps/details?id=com.vlcforandroid.vlcdirectprofree&hl=en
I want to integrate this app in my app. I have Url for video Streaming and i want to open this video in this app(Vlc Direct), Any idea?
I open this app using:
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage("com.vlcdirect.vlcdirect");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
But how it start with video streaming, Or any other Player for video Streaming?
More like,
Intent i = new Intent(Intent.ACTION_MAIN);
i.setComponent(new ComponentName("com.vlcdirect.vlcdirect", "com.vlcdirect.vlcdirect.URLStreamerActivity"));
i.putExtra("url", url);
startActivity(i);
Which supposes that the component, activity, and payload are as shown, and also that the activity is explicitly or implicitly exported -- I don't know the actual values, or if the activity is exported. vlcdirect doesn't document this, but you can
ask the developer, or
view the log as you stream from a URL within that app, to identify the component and activity; dedex and decompile the .apk, to confirm the payload; duplicate payload classes, if necessary; give up and fume after the developer ignores you, if the activity is not exported.
Ideally you would broadcast a "view the stream from this URL" intent, and vlcdirect or any other suitable app would pick it up, but I don't know if vlcdirect or any other app respond to such.
VLC needs to be explicitly told the type:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setPackage("org.videolan.vlc.betav7neon");
i.setDataAndType(Uri.parse("http://ip:8080"), "video/h264");
startActivity(i);
i.e. just "video/*" wouldn't work for me
Previous answers didn't work me. After a bit of searching I found the official docs here.
Basically, here it is:
int vlcRequestCode = 42; //request code used when finished playing, not necessary if you only use startActivity(vlcIntent)
Uri uri = Uri.parse("file:///storage/emulated/0/Movies/KUNG FURY Official Movie.mp4"); //your file URI
Intent vlcIntent = new Intent(Intent.ACTION_VIEW);
vlcIntent.setPackage("org.videolan.vlc");
vlcIntent.setDataAndTypeAndNormalize(uri, "video/*");
vlcIntent.putExtra("title", "Kung Fury");
vlcIntent.putExtra("from_start", false);
vlcIntent.putExtra("subtitles_location", "/sdcard/Movies/Fifty-Fifty.srt"); //subtitles file
startActivityForResult(vlcIntent, vlcRequestCode);
You can remove unnecessary parts for you.

launch facebook app from other app

How can I launch a facebook app from my app in android?
Looking at the latest Facebook apk (1.6), it looks like both "facebook://" and "fb://" are registered protocols.
facebook://
facebook:/chat
facebook:/events
facebook:/friends
facebook:/inbox
facebook:/info
facebook:/newsfeed
facebook:/places
facebook:/requests
facebook:/wall
fb://
fb://root
fb://feed
fb://feed/{userID}
fb://profile
fb://profile/{userID}
fb://page/{id}
fb://group/{id}
fb://place/fw?pid={id}
fb://profile/{#user_id}/wall
fb://profile/{#user_id}/info
fb://profile/{#user_id}/photos
fb://profile/{#user_id}/mutualfriends
fb://profile/{#user_id}/friends
fb://profile/{#user_id}/fans
fb://search
fb://friends
fb://pages
fb://messaging
fb://messaging/{#user_id}
fb://online
fb://requests
fb://events
fb://places
fb://birthdays
fb://notes
fb://places
fb://groups
fb://notifications
fb://albums
fb://album/{%s}?owner={#%s}
fb://video/?href={href}
fb://post/{postid}?owner={uid}¹
Sorry if I missed some... only played with a handful of them in the emulator to see if they actually work - a bunch of them will cause the Facebook application to crash.
¹ where postid is in the uid_postid format, e.g 11204705797_10100412949637447
To just start the default Launcher Activity:
Intent intent = new Intent("android.intent.category.LAUNCHER");
intent.setClassName("com.facebook.katana", "com.facebook.katana.LoginActivity");
startActivity(intent);
I did some research, because I wanted to find this out :). I found some ways how to start different activities easily. But I can not guarantee that this will work after upgrades of facebook. I tested it with my current facebook app and it works. At least I tested it with "adb shell" using "am start .....".
Basic is:
String uri = "facebook://facebook.com/inbox";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
the facebook.com part is not checked. you can even type: "facebook://gugus.com/inbox" having the same effect.
How to do this in adb.
1. Start adb shell through console: "adb shell"
2. run: "am start -a android.intent.action.VIEW -d facebook://facebook.com/inbox"
this will start the inbox activity.
Here some Uris with examples. I think they speak for themselves what they do.
facebook://facebook.com/inbox
facebook://facebook.com/info?user=544410940 (id of the user. "patrick.boos" won't work)
facebook://facebook.com/wall
facebook://facebook.com/wall?user=544410940 (will only show the info if you have added it as friend. otherwise redirects to another activity)
facebook://facebook.com/notifications
facebook://facebook.com/photos
facebook://facebook.com/album
facebook://facebook.com/photo
facebook://facebook.com/newsfeed
there might be additianl parameters you can give to certain of those uris, but I have no time to go through all the code of those activities.
How did I do this? check out apktool.
If any one want to directly open a photo
public Intent getOpenFacebookIntent(String pId) {
try {
activity.getPackageManager().getPackageInfo("com.facebook.katana", 0);
return new Intent(Intent.ACTION_VIEW, Uri.parse("facebook:/photos?album=0&photo=" + pId + "&user=" + ownerId));
} catch (Exception e) {
return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/"));
}
}
startActivity(getOpenFacebookIntent(pid));
where ownerId is the Facebook id of the user who uploaded this picture and pid is PhotoId
Enjoy :))
Launching of another application from your application in android, can be done only if Intent action you fire matches with intent filter of other application you want to launch.
As #patrick demonstrated, download facebook.apk to emulator and try to run that through adb shell command. It works fine..
Pass Intent filter and data as an Uri
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/groups/14531755***6215/")));
This directly opens facebook group having the id: 14531755***6215 inside fb app

Calling YouTube app using ACTION_VIEW intent Failing most of the time

I've written a small app to parse some RSS feeds from YouTube and launch videos selected by the user. To play the video, I'm using an intent:
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(videoAddress);
In order to call the YouTube app, if installed on the device.
The problem I'm having is that, of the population of videos I am using in my app, about 90% of them display a 'Cannot play video' error message: "Sorry, this video cannot be played.". A few of them work just fine from my app. The videos that do not work will play fine in the YouTube app if searched for and launched entirely from within the YouTube app.
Has anybody seen this behavior, or does anybody have any ideas for things to try? Obviously the YouTube app launches videos in a slightly different way internally than it does from an Intent request, but I haven't a clue how to get to the bottom of it.
I have the same issue. Are you sure that all of the video play correctly from the youtube app? In my case, on an old G1, the videos I can't play from my app won't play even if searched from within the youtube app.
I think the video encoding is not supported in some case and/or the combination of a slow cpu and slow network make the video not playable.
I've read about people just refreshing many times untill the video starts playing... I guess in thier care it was a network/buffering issue.
More discussion here:
http://www.google.com.tw/support/forum/p/android/thread?tid=3a62cdf7188384af&hl=en
For this reason my App (similar to yours) got a lot of bed comments. I republished it only for Android >=2.1 and I now I have fewer bad feedback.
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(YOUTUBE_URL)));
The above line of code works for my App.
What it basically does is lets Android handle the startActivity with available installed software on the device. Android in turn opens the IntentChooser and lets the user decide which appropriate software to use in this case a Browser and Youtube App to open the video.
Try it out and let me knwo if it works for you or f you have any other issues.
The most reliable method I have found for accessing youtube from an application is using the mobile site, try this instead (eg for searching):
String videoUrl = "http://m.youtube.com/#/results?q=ciaconna+bach";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(videoUrl)));
This solved the "Cannot play video' error message" that I was receiving.
I use this code:
String vid= Uri.parse(urlVideo).getQueryParameter("v");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + vid));
try{
startActivity(intent);
}
catch (ActivityNotFoundException ex){
Log.e(TAG, "Couldn't find activity to view this video");
}
May be works for you.
I have got the same problem only with HTC Hero 2.1. You can force the intent to launch the htc flash player instead of the Youtube app. With the flash player app I have not had any problem:
Uri uri = Uri.parse("vnd.youtube:" + videoUrl);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
String availableFlashPlayer = availableFlashPlayer();
if (availableFlashPlayer != null) {
// launch the intent with the available flash player
intent.setPackage(availableFlashPlayer);
}
startActivity(intent);
The availableFlashPlayer method:
public String availableFlashPlayer() {
String availableFlashPlayer = null;
String FLASH_PLAYER = "com.htc.flash";
PackageManager pm = getPackageManager();
try {
ApplicationInfo ai = pm
.getApplicationInfo(FLASH_PLAYER, 0);
if (ai != null) {
availableFlashPlayer = FLASH_PLAYER;
}
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
}
return availableFlashPlayer;
}
You can also check the Adobe Flash Player:
String FLASH_PLAYER = "com.adobe.flashplayer";
Alternatively, you can force the intent to launch the Android Browser as follows:
Uri uri = Uri.parse(videoUrl);
String packageName = "com.android.browser";
String className = "com.android.browser.BrowserActivity";
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setClassName(packageName, className);
startActivity(intent);

Categories

Resources