I need to execute Intent, but I also need to set application directly. I know that I can do it using Intent.setPackage(), and I need to set Android Media Player by default. Please, tell me, how can I do it? Thank you.
but I also need to set application directly
This is almost never a good idea.
I need to set Android Media Player by default
There is no "Android Media Player". Different devices will have different built-in "media player" apps.
Related
I wrote some code to play the shuttersound for Android using the camera2 API. The code is:
MediaActionSound mediaActionSound = new MediaActionSound();
mediaActionSound.play(MediaActionSound.SHUTTER_CLICK);
I've tested on more than ten devices. The problems are:
The actually play a different sound that the built-in camera.
Different devices actually play different sound. (It seems that the device manufacturer each has installed a different sound fine.)
There is some information about this file:
/system/media/audio/ui/camera_click.ogg
... but I'm not sure if this is the sound file used. And if so, why do they all sound different and not the same as the built-in camera.
The solution I'm seeking:
Either:
Play exactly the same sound as with the built-in camera. How do I do this?
or
Install a custom sound file into my app and play this same sound across all devices. (However, this method is secondarily preferred because we have to find a custom sound file.)
Please advise.
If the default camera app has its own shutter sound, it's unlikely you can get to it - it's likely either baked into the app APK, or some custom addition to that OEM's set of device sounds that isn't visible to non-system apps.
The main reason to use MediaActionSound to be compliant with the expectation in some countries that camera shutter sounds are not silenceable. MediaActionSound will still play a shutter sound even on a fully-silenced device in such countries, without the developer having to worry about it.
Otherwise, you could just play whatever sound you want on shutter press, if complying with the shutter sound enforcement isn't critical - or you can use your own sound when shutter sound muting isn't enforced (you can check via canDisableShutterSound), and fall back to MediaActionSound in places where shutter sound shouldn't be silenced.
It rely on your decision.
If you want to make your app's brand, just use the one you like or treat the user with their familiar sound. Your don't have to complicate it
I am intended to make an app that stream live videos from one android phone to other one via Bluetooth,i need a simple player and there is no need to save the file,just play it.
My knowledge about stream in java is not enough and I really don't know where to start!
Please help me in finding any solution. Any help will be appreciated.
There is a sample android project to do streaming live video and allows you take photos and record videos from remote phone via bluetooth.
BluetoothCameraAndroid
Android allows you to get frames as byte array using camera, you can use that api to get frames and send it across. But the problem is throttling the sending rate. That also has been handled in that project.
In marshmallow and above devices, you have to give permissions
manually in settings. This project does not include runtime
permissions
Xuggler is a Java opensource library that works with streaming and modifying media on the fly. you can start from it at:
http://www.xuggle.com/xuggler/
I've made an app in Android Studio which is essentially a parametric EQ with some additional features.
The app takes signal from the microphone source (whether the built-in mic or external mic). The signal is then passed through biquad filters and out to the speakers/earphones. I used LibPb to handle the signal processing.
Now, I want all the audio that would be coming out the speakers to be routed through the app.
In other words, any music playing or calls, I want the audio to also be passed through the filters in my app.
I have tried to find articles/resources on this topic but haven't found much.
I'm guessing that it can be done via Audio Focus or Media Router or something along those lines, but I cant figure it out!!
Firstly, is this possible?
Secondly, any code or hints as to how to go about it?
Any help is much appreciated!!
I was playing around with the new Google+ application on the Android and I had a technical question that I couldn't seem to find online. How does the instant upload hook into the native camera application?
I can turn on a feature in the Google+ application and any pictures that I take with the native camera app are automatically uploaded to a private album on Google+. And this seems to be true whether the Google+ application is currently running or not. Is there any type of hook that I can register a callback event for in my application to access "just-taken" pictures for some post-processing goodness? I'd really like to tap into this functionality for an application that I am currently writing.
Any insight or hints in the right direction are greatly appreciated! Thanks!
Not entirely sure exactly how Google+ does it, but one way that would work is to use the ContentObserver interface: grab the MediaStore.Images.Media ContentProvider and attach a ContentObserver to it. Anytime a camera image is added, you'll get a notification and you can process it accordingly (including uploading).
Same technique would work for just about any ContentProvider that properly handles ContentObservers (which I'm assuming is all ContentProviders, but you never can tell).
Thanks to Femi's answer in this post, I was able to take what he said and figure out how to emulate Google+'s Instant Upload feature. I wrote a tutorial about it here:
http://www.jessechen.net/blog/how-does-google-plus-instant-upload-work/
I'm looking for a way to control the default Android media player from my own service. I'm NOT interested in playing media from my service or activity; I want to control the existing application, which consists of an activity (MediaPlaybackActivity.java) and more importantly a service (MediaPlaybackService.java) located in packages/apps/Music/src/com/android/music/. Ideally, I would like a solution that is independent of the version of Android.
I have figured out how to do pause/play/stop/next/previous operations using Intents. I can intercept track change events using a broadcast receiver. I can also get a list of playlists and the contents of each playlist. What I would like to be able to do is instruct the MediaPlaybackService to play a specific file/song. Again, I don't want to play this song in my application; I want the Android default media player to play it.
I have tried two approaches so far:
I imported the IMediaPlaybackService.aidl file from packages/apps/Music/src/com/android/music into my own application, and used this to bind to the MediaPlaybackService. On Froyo, this works great; I can pass a path to the openFile method, and the service will play the file. However, on Gingerbread, I get an error: Permission Denial: Accessing service ComponentInfo{com.google.android.music/com.android.music.MediaPlaybackService} from
pid=17721, uid=10058 requires null. Finding a workaround to this error would be a good temporary solution, but it's not future-proof. This service may well change again in future versions of Android.
Starting the media player via an ACTION_VIEW Intent. This also works; however, as expected, the media player UI is brought to the front, which is not ideal.
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(someUri, "audio/mp3");
startActivity(intent);
Is there any other way to accomplish this? Is there an Intent I missed that would instruct the media player to play a specific song? Or alternatively, is there away to start an activity in the background, or to start an activity and immediately switch back to the previous one?
Sorry, there is no supported way to do this. All of the stuff you are describing is using private implementation details, and as you have seen is not robust. If you want to play music, you should do it in your own app.
I'm looking for a way to control the default Android media player from my own service.
There is no "default Android media player". The application you are referring to may exist on some devices and will not exist on others. AFAICT, few devices will have what you think is the "default Android media player" going forward -- those not already running proprietary media players from device manufacturers may have the new proprietary Google Music app.