I'm developing an Android music player and so my app should be able to detect volume key presses even when no Activity of my app is open and the screen is off(a background service is playing the media). I was thinking that it seems crystal clear that i should detect volume key presses from my service but as I searched the net, I got that it is impossible(e.g. as described here). so what should I do?!!!
You'll need to create a service, because activities don't run when screen is off
You need to run player in service. Also, you must set media type as music.
Related
I am writing a screen recording program like ZD soft Screen recorder
For this, I need to record video in the foreground service so that I can record video from all applications (outside my application environment).
How should I do this?
I tried different ways but did not get an answer
I am doing a simple application on Android studio that plays a song. I managed to make a song play when I get to the specific activity. My question is- when I go out of my app(I leave it working in the background) and go back into it, or when I rotate the phone, the song starts playing from the begging. How do I make the song keep on playing from the place it stopped when I went out of my app/ how do I make the song keep on playing when I rotate the phone?
You may want to look into MVVM design pattern as live data is life-cycle independent, What is happening is common. When you rotate your screen or go out and back into the app, the activity cycle is being affected. Your activity literally restarts thus restarting your song.
Here are a few links that may help you on your way. Best of luck.
https://developer.android.com/guide/components/activities/activity-lifecycle
https://blog.mindorks.com/mvvm-architecture-android-tutorial-for-beginners-step-by-step-guide
Is it possible to track registered users of my android app and get information about what music is playing in their music player? If it can be tracked then is it legal to display the music listening information (just track ID, artist name, listening time) in their profile? The user's permission will be given ofcourse.
Basically, I am trying to build an app where registered users can see what other users are playing on their device music player.
If your app can play music, then you can definitely get the details you want, and so long as you have asked for permission from the user i.e in the 'Terms Of Use', you can legally publish that data. If your app is not playing the music, android security policy does not allow one app to view the data of another. In this case your app has no way of knowing which app is currently playing the music, and thus no way of getting the data you require. If on the other hand, you intend for the app to be run on rooted devices, then you can pretty much do anything you want...
So I made a website someday, and now via webview and the YouTube Api I made it possible to listen to the music on my phone.
But... as soon as I close my app it stops playing the music.
How can I possibly add a music player and make it so the music keeps playing after the phone goes on standby mode?
Thank you very much!
Even thought I haven't deal with Youtube API for Android, I think that what you are trying to do is impossible. Even the Youtube App doesn't keep music playing after the phone goes on standby mode. That's their policy about music videos on Youtube.
I am working in an online radio streaming project, where I am playing audio with mediaplayer from an URL. The music is playing and working fine. But I am stuck with the play,pause functionality regarding to the state of the player activity. I want such that when the app will be exited by home button press then music will keep playing, but when a phone call rings then the music will be paused and after the phon call the music will resume. And also when user opens another app then the music will continue playing in background. (as the default music player of android works)
But still what I did results almost my desired destiny, but something is missing, like I have started the music in onResume and stopped the music in onDestroy.By doing this the music keeps playing in background when I press home button, but when a phone call comes and recieved it continues playing which creates a disgusting situation, but when another app is turned on then the music goes off. How should I manage the MediaPlayer that will work like what I want? Any suggession?
Note: I am not using any service here, just an AsyncTask class to play the music.
The topic of MediaPlayer as background service is covered in multiple sources such as this one.
http://www.codeproject.com/Articles/258176/Adding-Background-Music-to-Android-App
You can also find this in the Android official documentation here
http://developer.android.com/guide/topics/media/mediaplayer.html
Hope that helps.