I'm trying to get a notification that you have a button, when you click on it you should call my service, which controls the sound playback.
Here is my notice with the intention
Intent intent = new Intent(context, AudioStreamService.class); Random generator = new Random(); PendingIntent i = PendingIntent.getActivity(context, 579, intent,PendingIntent.FLAG_UPDATE_CURRENT); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(title) .setContentText(text) .setPriority(NotificationCompat.PRIORITY_DEFAULT) .setLargeIcon(picture) .setTicker(ticker) .setNumber(number) .setOngoing(true) .addAction( R.drawable.ic_action_stat_reply, res.getString(R.string.action_reply), i); notify(context, builder.build());
Here is a start to my service
public int onStartCommand(Intent intent, int flags, int startId) { Log.e("APP ID", "APP ID - service called "); if(isPlaying){ stop(); } else { play(); } return Service.START_STICKY; }
The log does not start when called from an action in a notification. But the service is used by the button in the application and works fine. The log is called in the same way as the commands below.
android android-intent android-service android-notifications
Dandrews
source share