hey every one I wonder how can I open specific post, album or video from android app in facebook app, I used this code to open specific post but it doesn't work
mActivity.getPackageManager().getPackageInfo("com.facebook.katana", 0);
String uri = "fb://post/" + mData.get(position).getmPostID();
Intent viewIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(uri));
I want to open this post
https://www.facebook.com/Y.Anti.coup.D/posts/707105232705409
Sorry for my bad English and I hope that you understand my problem
Related
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
When trying to play a Video on Android, the app is prompting the user to select the player.
In code, I am doing the following. Is it possible that I select the player so the user wont' be prompted?
String url = (String) v.getTag();
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "video/*");
startActivity(intent);
Below is the image this is shown to the user:
Edit pasted as answer
intent.setPackage("com.sec.android.app.videoplayer");
I take it back. That might cause a problem on some phones. It worked on S4. However,It might not work on others. More work needs to be done.
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)
I am newbie to android and development world. I need help to solve this problem.(scenario as follows)
I have created one android app using HTML5 and CSS and bundle it out using phonegap.
Now I need to display PDF file in this app with two options for user whether first download and then read or second read online
So My problem is, I am not able to dispaly PDF in app.
How could I achieve this? please help . I am trying to solve it from last 4 days and tried out each and solution which is already given in forum , but still no success.
It would be great for me if someone ans step by step procedure or one example to refer.
Thank You
Minal
This may help: How to open a PDF via Intent from SD card
The basic idea is to get a pdf app to render the pdf for you, and your app just kicks off an intent to do that.
try this code
private void openBook() {
File file = new File(mRealPath);
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setDataAndType(path, getString(R.string.application_type));
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(FirstTab.this,
getString(R.string.no_application_found),
Toast.LENGTH_SHORT).show();
}
}
you can open pdf file via intent like this
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/example.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),”application/pdf”);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
As the docs say: "ACTION_GET_CONTENT could allow the user to browse over the web and download the desired data".
And that's what I need, from Google Images. Although, if I use this intent's type the app crashes (I suppose it only expects ACTION_VIEW to open the browser):
Intent intent = new Intent();
intent.setData(Uri.parse(url));
intent.putExtra("return-data", true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, PICK_IMAGE);
It needs to (edited to clarify what I need):
Estabilish the connection to the web browser
The URL to Google Images
Retrieve the image's URL after the user has chosen one (it needs to close the browser, the ACTION_VIEW just keeps on going until the user decides to close it and does not retrieve any information).
As far the URL I have is this one, but it needs something else because it is going to a default search, not for images:
String url = "http://images.google.com/search?q=" + imagename;
I appreciate any help.
Try using the following url. It works fine for me in my app:
"http://images.google.com/search?num=10&hl=en&site=&tbm=isch&source=hp&biw=980&bih=710&q=" + YourQueryString
You need the tbm query parameter set to the value isch for image search. So the minimal URL would look like:
"http://google.com/search?tbm=isch&q=" + queryString