![]() By giving Pending Intent to another application, we are. Direct reply is a feature introduced in Android 7 that allows the user. Our current object can be handed to other applications so that they can perform the action, your described on your behalf at a later time. Now this works if the activity is currently in the foreground. You are reading a sample chapter from the Android Studio 3.0 / Android 8 Edition book. We’ll create an Intent and wrap it into a PendingIntent: //Creating a regular intent Intent intent new Intent (this, SomeActivity.class) // Creating a pendingIntent and wrapping our intent. MBuilder.addAction(R.drawable.ic_stat_stop, "Stop", stopPendingIntent2) ![]() StopIntent2, PendingIntent.FLAG_UPDATE_CURRENT) PendingIntent stopPendingIntent2 = PendingIntent.getBroadcast( this, 0, I also tried to check to send an broadcast (i have a broadcast receiver working to communicate from the service to the activity) Intent stopIntent2 = new Intent(MusicPlayerNew.STOP_MEDIAPLAYER) Now in the onResume()-method of my activity I check with getIntent().getStringExtra() for the "STOP" extra, but the intent I retrieved via getIntent() has no extras set :( MBuilder.addAction(R.drawable.ic_stat_stop, "Stop", stopPendingIntent) StopIntent, PendingIntent.FLAG_UPDATE_CURRENT, null) PendingIntent stopPendingIntent = PendingIntent.getActivity( this, 0, ![]() Here is how it is declared in the service starting the stream: Intent stopIntent = new Intent( this, MusicPlayerNew.class) The notification working fine so far, I am having trouble with the stop action item. When a stream is started a notification should be triggered and an stop button for the stream should be displayed in the notfication. I am trying to add an Notification action item in my app which is a music player.
0 Comments
Leave a Reply. |