How to run a function in service when click on actionClick of Notification? <p>I have written an app. But i cant solve my problem. I have an AlarmManager to push Notification. And now I want to have a button on my Notification. when I click that button, my app will run a function in service ( post request to thingspeak ) but i have tried many ways but i cant solve it. Help me plz! I have 4 classes: Activiti, Alarm_reciever, HttpRequest and RingtonePlayingService. here is my code to push notification. </p> <pre><code>public int onStartCommand(Intent intent, int flags, int startID) { Log.e("start", "startingcommand" + startID + ": " + intent); long[] v = {500, 3000}; Intent intent1 = new Intent(this.getApplicationContext(), MainActivity.class); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent1, 0); Notification mNotify = new Notification.Builder(this) .setContentTitle("Smart Mini Garden Alarm") .setContentText("Click để kiểm tra và tưới cây !!! ") .setTicker("Đã tới giờ tưới !!") .setSmallIcon(R.drawable.iconchuan_72) .setVibrate(v) .setContentIntent(pIntent) .setAutoCancel(true) .build(); NotificationManager mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); </code></pre> <p>I want to have a addAction ( button in notification bar ) And here is my httpRequest i want to run when i click On button in notification</p> <pre><code>public void postData() { String fullUrl = "https://api.thingspeak.com/update?api_key=RICJCNNCNMDURNDS&amp;field1=1" HttpRequest mReq = new HttpRequest(); String data = ""; String response = mReq.sendPost(fullUrl,data); </code></pre> <p>What i can do next to solve my problem.</p>