Control MediaPlayer from personal app in background - android

Have searched for solution but none has worked as i want.
Am developing a app for personal usage and want to control MediaPlayer from it, while application is in background. Is it possible and if so, how to achieve that ? Targeting Android 6.0+ and to control Spotify
Currently I'm only able to do that in a Rooted phone with exec command input keycode but on unrooted phone this only works while app is in foreground.

Found the best working example here:Control Spotify
Works great on A7.1.1
However when Spotify I brought to front, it's state is reset to home-screen.

Related

Media stops playing after screen turns off on cordova/phonegap Android app

I think the app might have been paused or killed when phone sleeps, so I believe music stops after a while when screen off. This works if device is in charging state. I have heard running it as a background/service may fix this but I am not really sure how to proceed specifically on Cordova app. I am using cordova media plugin and music plays after user click on a button that invokes media play api. Please guide..
One solution was to to put the app to background and this seems to fix the issue.

Prevent Android from closing a Progressive Web App playing audio in the background

I've written a progressive web app which plays music using the Web Audio API. A common user journey is to start the music playing, then change to other apps whilst still listening to the music. This works fine for a while, until android decides that it needs more resources for the other apps and closes down my PWA without warning.
Is there a way to hint to the browser and OS that despite not being in the foreground, the user is still using a particular web app?
I'm fine for it to be tidied up in the background when the music is paused, but not whilst the user is still listening to something.
The main browser I'm interested in is Chrome for Android (though something platform agnostic would be ideal).
You can't, today. This is somewhat related to MediaSessions (https://wicg.github.io/mediasession/), but you really need a background app, which is not a concept that's yet supported by the web. (It's related, also, to ServiceWorkers and Web Workers, but again, not precisely. It's really a difficult scenario, as such an app has a definite ability to drain batteries.)
I have created a bug for this Chrome bug
If you have steps to reproduce, please comment on the bug

Open Android App from Dialer

I have implemented a Broadcast Receiver to open my app from the launcher. The number to open is #1234#
Now it works perfectly in some devices while it doesn't in some. Now my question is how is this even possible?
If it works, then it should work in all devices isn't it? Also I need suggestions on what would be the best practice to ensure that it works on all devices.
Thanks.
Now my question is how is this even possible?
Yes it is pretty much possible.
If it works, then it should work in all devices isn't it?
No, Reason behind your implementation not working can be but not limited to are given below.
1) Every Phone Manufacturer tweak Android OS code(As Android is Open Source). There can be chance of have given priority to System Apps first then public
apps.
2) There can be other apps(System/Public both) running on the phone, which are listening on the same BroadCast Intent and taking action before your app does anything.
3) Phone are slow and your receiver getting command little later then expected!!
Share more details on your testing to get more feedback.

Intel XDK HTML Android app, run in background?

So I've created a 'Sound App' that needs to run when the phone is locked.. After a minute of being locked the sound just cuts out. Anyone suggest a fix?
The app is created out of basic HTML5, css & js. Audio needs to continue playing when the phone is locked.
Thanks in advance! :D
You'll need to use a plugin that provides a background service. In order to preserve battery, mobile devices do not normally allow applications to continue to run once they lose focus. After a short period of time they are paused, and if RAM is required to run other apps, they might be stopped entirely. See the pause/resume events for a little more info: http://cordova.apache.org/docs/en/3.5.0/cordova_events_events.md.html#pause
Here's a project from devgeeks, who is an accomplished Cordova developer, regarding background audio on iOS: https://github.com/devgeeks/ExampleHTML5AudioStreaming -- also, this blog by Andrew Trice may be of value, he is also an experienced Cordova developer: http://www.tricedesigns.com/2012/01/25/low-latency-polyphonic-audio-in-phonegap
You might want to search for "cordova phonegap app background audio" for more solutions.

Is it possible to have a second screen device launch an application on Google TV?

I've been reading the AnyMot protocol and the fling is mentioned wherein a second screen app can launch the YouTube app. Could a tablet application launch say the Flixter, Pandora or the Goolge Music app without it being a remote control emulator. If so would the AnyMot protocol be what's used?
Thanks
Anymote is a very much adequate for that. If, you want to do an app like "Able Remote", you'll need to put a small app on the TV which will tell you what apps are present. But for what your asking, it's doable w/ just Anymote.

Categories

Resources