How to send PendingIntent to my service inside Intent

android

Solution

I success!

see this:

PendingIntent pendingIntent;
Intent ownIntent;

ownIntent = new Intent(Intent.ACTION_SENDTO);
ownIntent.setData(Uri.parse("sms:0523737233"));
ownIntent.putExtra("sms_body", "The SMS text");
Log.e("abc", "7");
pendingIntent = PendingIntent.getActivity(this, 0, ownIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
Log.e("abc", "9");

ownIntent.putExtra("pendingIntent", pendingIntent);
ownIntent.putExtra("uriIntent", ownIntent.toUri(0));
startService(ownIntent);

and in the service:

PendingIntent pendingIntent = (PendingIntent) intent.getParcelableExtra("pendingIntent");
pendingIntent.send();

Problem

I want to tell my service what to do when it finish to perform an action. So I want to send the service a `PendingIntent`, so it can start it (by using `PendingIntent.send()`) ``` PendingIntent pendingIntent; Intent newInt; newInt = new Intent(Intent.ACTION_SENDTO); newInt.setData( Uri.parse( "sms:052373")); newInt.putExtra("sms_body", "The SMS text"); pendingIntent = PendingIntent.getActivity(this, 0, newInt, 0); ``` Now the question how to start to attach the `pendingIntent` to the `pendingIntent`? I tried this for example: ``` NewIntent.putExtra("pendingIntent",pendingIntent); startService(NewIntent); ``` But it doesn't work. And in the service: ``` PendingIntent pendingIntent = (PendingIntent) intent.getParcelableExtra("pendingIntent"); pendingIntent.send(); ```

Original source