Display player in Android notifications area

Asked

Viewed 756 times

13

I created an app that transmits a Streaming radio, but if I "minimize" the application it continues playing.

So I’d like to know how I can get you to open a box at notification list android, type the app Play Music

Only that I believe that the real and biggest difference between apps is that my radio is made by Phonegap which boils down to HTML5 instead of pure java.

  • 3

    I strongly suggest you read: When to put the language name in the title?

  • 1

    I edited the question, because the problem is totally oriented to the phonegap and should avoid using irrelevant tags, something else removed the link because it does not help anything with doubt. A doubt Pedro, Voce want to put the player where the notifications are? Because if it is, then pushs do not seem to be part of the problem (despite staying in the same location), could explain better?

  • 1

    Guilherme Nascimento, simply wanted that when the person minimize the radio APP appear a cixa like that of Play Música only with the pause and play button and the radio icon.. Sacks??

  • 1

    That’s why I asked, the title talks about pushs, but you understand that you want to create a widget in the notification list. In other words, the only thing I asked him friend is "what notifications have to do with the problem", I did not ask for ill is that I wanted to try to improve the title of your question so that more people can be interested and try to answer your question :)

  • Solved your problem?

  • Take a look at this example on Github. It has what you’re looking for. https://github.com/iammert/RadioPlayerService

Show 1 more comment

2 answers

2


You can use the Cordova Music Controls Plugin

cordova plugin add https://github.com/homerours/cordova-music-controls-plugin

It’s very easy to integrate it with your app.

0

You can set up a custom notification and add more useful information to the user. When mounting your notification, if you want to put your own layout (and with that more information pro usuario) you would need to add the "Builder.setStyle function()".

An example would be like this:

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.drawable.notification_icon)
    .setContentTitle("Event tracker")
    .setContentText("Events received")
NotificationCompat.InboxStyle inboxStyle =
        new NotificationCompat.InboxStyle();
String[] events = new String[6];
// Sets a title for the Inbox in expanded layout
inboxStyle.setBigContentTitle("Event tracker details:");
...
// Moves events into the expanded layout
for (int i=0; i < events.length; i++) {

    inboxStyle.addLine(events[i]);
}
// Moves the expanded layout object into the notification object.
mBuilder.setStyle(inBoxStyle);
...
// Issue the notification here.

Google has good documentation for this: https://developer.android.com/guide/topics/ui/notifiers/notifications.html?hl=pt-br

  • 1

    Maybe this link is a good tip, but for a reply, it would be important to transcribe the most relevant parts so that the essential can be read here on the site itself. Two links that can help you make the most of Sopt: [Tour], [Answer] .

  • It would be even nicer to help with answers that have to do with the doubt put, CITO 0 original ".... The biggest difference between applications is that my radio is made by Phonegap which boils down to HTML5 rather than pure java." , it always seemed to me that staying inside the topic is important @Bacco.

  • Hello, @Camilayamamoto, note that my comment had been made before the author’s edition: https://answall.com/posts/150911/revisions - In cases where you understand that the post is not an answer, remember to use the site’s flags (link "signal", just below the post).

  • I got it, I got it. But I did not understand any guidance to @Nimai Marchiori with regard to him dealing with android , when the doubt is given to Ordova... or he is well placed within the subject? See, I wonder why I’d like to know more about OR policy.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.