iammert / RadioPlayerService

Android service library which uses AAC Player. Ready to use Radio Player Service.
254 stars 91 forks source link

how to open the app when click on notification ? #52

Closed Ishu25 closed 7 years ago

Ishu25 commented 7 years ago

I want that whenever I click on the notification then it will open the app directly . But as know I it would only open the the home screen of the mobile whenever I click on notification Rather then opening the app ?

chehanr commented 7 years ago

Try this.

Ishu25 commented 7 years ago

Thanku so much @chehanr , ur code works . But This opens the new activity and I want to resume the activity where I Leave or close the app . I mean If app is playing then there would be a stop button but when I open that activity from notification then it will open the new activity where play button is showed rather than resuming the activity . So plz provide the code so that main activity resumes when click on notification rather than open new activity. Thanks,

chehanr commented 7 years ago

You should try saving the play/ stop state of the button on Shared Preferences. so when you reopen the app the button remain on the play state rather than stop.

Ishu25 commented 7 years ago

@chehanr can u provide any code for this ?

chehanr commented 7 years ago

A better method is,

     if (mRadioManager.isPlaying()) {
            mControlPlay_Pause.setImageResource(R.drawable.ic_pause);
        } else {
            mControlPlay_Pause.setImageResource(R.drawable.ic_play_arrow);
        }
Sarun1001 commented 6 years ago

@Ishu25 add in your manifest under your launching activity after the above code implementation eg : <activity android:name=".RadioMainActivity" android:theme="@style/AppThemeBar" android:launchMode="singleTop" android:configChanges="orientation|screenSize"/>