How to cast in IntentService::handleIntent the CustomResultReceiver passed as an intent extra
<p>I am trying to cast the Intent::extraParcelable received, to my custom RestResultReceiver like this</p>

<pre><code>public class APIHttpV1Service
    extends IntentService
{

    ...

    protected void onHandleIntent (Intent intent)
    {
        final int apiCall = intent.getIntExtra("uri");
        final RestResultReceiver resultReceiver = intent.getParcelableExtra(RestResultReceiver.EXTRA_ID_RESULT_RECEIVER);

    //  check if the uri is correct
        if( apiCall == -1)
        {
        //  TODO call failed as we didn't provide any URI
            resultReceiver.send(RestStatus.ERROR, Bundle.EMPTY);
        }

        ...

    }
}
</code></pre>

<p>and this is the RestResultReceiver</p>

<pre><code>public class RestResultReceiver
    extends ResultReceiver
{
    private static final String TAG                     = "com...RestResultReceiver";
    public static final String EXTRA_ID_RESULT_RECEIVER = "com...RestResultRecevier.Receiver";

    private Receiver __mReceiver;

    public RestResultReceiver(Handler handler)
    {
        super(handler);
    }

    public void clearReceiver()
    {
        __mReceiver = null;
    }

    /**
     * Set the receiver
     * @param receiver the object getting called back using onReceiveResult
     */
    public void setReceiver( Receiver receiver )
    {
        __mReceiver = receiver;
    }

    @Override
    protected void onReceiveResult(int resultCode, Bundle resultData)
    {
        if (__mReceiver != null)
        {
            __mReceiver.onReceiveResult(RestStatus.getEnum(resultCode), resultData);
        }
        else
        {
            Log.w(TAG, "Dropping result on floor for code " + resultCode + ": "
                    + resultData.toString());

        }
    }

    public void send(RestStatus resultStatus, Bundle resultData)
    {
        super.send(resultStatus.getCode(), resultData);
    }

    /**
     * Interface to implement for objects doing rest service call
     */
    public interface Receiver
    {
        public void onReceiveResult(RestStatus resultStatus, Bundle resultData);
    }
}
</code></pre>

<p>At runtime I have a java.lang.ClassCastException exception. I am just wondering why I can get my RestResultReceiver.
If I use </p>

<pre><code>final ResultReceiver resultReceiver = intent.getParcelableExtra(RestResultReceiver.EXTRA_ID_RESULT_RECEIVER);
</code></pre>

<p>it doesn't throw any error but I can't call my custom send function obviously.</p>

<p>Any idea?</p>

<p>Thx a lot for any help you could provide :)</p>
