Note that there are some explanatory texts on larger screens.

plurals
  1. POExecute Custom method in class using an Intent android
    primarykey
    data
    text
    <p>I want to call a custom method in a class which can be passed in Intent. In the receiver side of Intent, I want to call my custom method of the class. Lets say I have a class extends ResultReceiver which two methods</p> <pre><code>class MyClass extends ResultReceiver { public doBefore(){ //custom method Log.d("sdf","before"); } public doAfter(){ // custom method Log.d("sdf","After"); } @Override public void onReceiveResult(final int resultCode, final Bundle resultData) { } } </code></pre> <p>I want to pass the MyClass in the Intent to another Activity or Service. So Lets say i am passing the MyClass to a service</p> <pre><code>MyClass mcl = new MyClass() final Intent intent = new Intent(mContext, MyService.class); intent.putExtra(INTENT_EXTRA_RECEIVER, mcl); </code></pre> <p>In MyService class, I get the intent in onHandleIntent() method. </p> <p>Method in MyService Class</p> <pre><code>@Override protected void onHandleIntent(Intent intent) { MyClass eval = (MyClass) intent.getParcelableExtra(INTENT_EXTRA_RECEIVER); eval.doBefore(); // Is this possible?? eval.doAfter(); sendSuccess(intent, null); } </code></pre> <p>Now I want to execute the two methods in the of the class "MyClass". onReceiveResult() in the "MyClass" is called at the end but I am not able to call my custom method. I dont want to start an activity or service. I want to my custom method to be executed.</p> <p>Is there anyway I can call my custom method from the Service or Activity like ResultReceiver's onReceiveResult().??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload