How to play a few video in youtube player on Java, Android? - java

I have a few videos for Android. My app plays it by code:
Intent youtube=new Intent(Intent.ACTION_VIEW, Uri.parse(link));
startActivityForResult(youtube, 100);
But it code play 1 video from list. How can I put a few video for Intent in order to standart player play it in series?

Playlists are not supported. You will have to write your own,
create a list of videos
Lauch the new activity using startActivityForResult
In the onActivityResult just launch the same activity with the new video file.

Related

Search history in android Sound Search

I'm using this intent for calling google music search. Google search will be shown after detecting sound.
Can I get the search history from this activity?
Intent intent = new Intent("com.google.android.googlequicksearchbox.MUSIC_SEARCH");
startActivity(intent);

Open the default photo gallery app

I want the gallery app to be launched in a separate window, not in my app. I also dont want to choose a picture, I just want to open the default gallery app.
Some questions are very similiar to this one, but they all open the gallery not as a standalone app, always inside of the app which has called
startActivity(intent);.
see here. This is my app called SM2. inside, the default gallery app is visible, which is not the desired behaviour.
The following code has no use if there is no package named 'com.android.gallery' on the phone:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.android.gallery");
if (launchIntent != null) {
startActivity(launchIntent);//null pointer check in case package name was not found
}
this opens a gallery in my app, not as wished as a standalone task:
Intent intent1 = new Intent(Intent.ACTION_VIEW, Uri.parse(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_MOVIES)));
startActivity(intent1);
and this does also open the gallery in my app:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"content://media/internal/images/media/"));
startActivity(intent);
It is launched inside of the application
It is being launched in your task. You can use FLAG_ACTIVITY_NEW_TASK on your Intent to have it launch in its own task.
I also dont want to choose a picture, I just want to open the default gallery app
You are welcome to try using CATEGORY_APP_GALLERY, though not all gallery apps might have an activity that supports this.

How to transfer a search string to music apps on android from another app

I'm developing an app for android that calls for other music apps, and I would like to transfer from my app to the music app I'm calling a search string (For example: "Thriller by Michael Jackson").
I know that Google's voice search for android, and also Dragon personal assistant, can do this.
I don't control what the music apps accept, only what my app is sending though the intent I'm creating when starting a new activity.
Does anyone know how to do this?
Thanks.
You can pass the search string from your activity to the music app activity that you want to open via a bundle.
Intent i = new Intent(//Insert required action for the activity you want to open);
// you should get the text from a widget like editText here
String searchString ="Thriller by Michael Jackson";
//Create a bundle
Bundle bundle = new Bundle();
//add the search string to the bundle
bundle.putString("SEARCH_STRING",searchString);
//add bundle to intent
i.putExtras(bundle);
//call the music app's activity
startActivity(i);

using intent for launching music player

im trying to launch the music player but it just doesn't work.
Intent intent = new Intent(MediaStore.INTENT_ACTION_MUSIC_PLAYER);
startActivity(intent);
The app crashes,it suppose to be simple but i have no idea why it doesn't work...
It might be raised ActivityNotFoundException. right?
That intent is deprecated in API Level 15 (ICS MR1).
And I guess your phone manufacturer missed that intent in music app.
Use http://developer.android.com/reference/android/content/Intent.html#CATEGORY_APP_MUSIC instead.

Camera control inside an Android application

I am building an application for Android 2.2 which is based on a photo library. There is an option to take picture from camera and use it in the application. I am expecting:
To enable the camera from the application.
To take the picture.
To automatically close the camera and show the captured picture inside the application
Unfortunately, I am not able to get the captured image to the application. Once photo is taken, camera is not closing automatically or returning to the app. Now I have to click the back button to go to the app and select the picture manually select from SD card. Camera is opening through intent and I am using the following class.
http://developer.android.com/reference/android/hardware/Camera.html
You need to do two things. Start the Camera app and tell it where to store the picture that it takes:
File photo = new File(Environment.getExternalStorageDirectory(), "myFile.jpg");
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
startActivityForResult(intent, myRequestCode);
When the user closes the Camera app, you app and Activity will be resumed. So you must override onActivityResult to get the result:
if (resultCode == myRequestCode){
File photo = new File(Environment.getExternalStorageDirectory(), "myFile.jpg");
// open it, show it, insert into MediaStore whatever
}
If you don't provide the place to save, you can alternatively retrieve it using either intent.getData or intent.getParcelableExtra using Intent.EXTRA_STREAM.
I guess .. you are doing similar to the below code
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
// request code
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
using startActivityForResult instead of startActivity.. whenever you are done with your camera.. press ok.. and you will come back to your activity.. then in your activity onActivityResult callback will be called. here you will get the data for the clicked image.
Thanks.

Categories

Resources