0

I want to call a web service from my android app IntentService (onHandleIntent method) but as they said its not safe following this url start async task from onhandleintent what is the best method to call a web service from onHandleIntent and getting data returned by the web service to use it?

    @Override
protected void onHandleIntent(Intent intent) {
    try{

                getTransactions get=new getTransactions("0");
                get.execute(d1,d2);
    //Here in on postExecute i need to do something with the results

        }


    }
    catch(Exception e)
    {
        writeToFile("Exception" + e + "\n");
    }

    MyReceiver.completeWakefulIntent(intent);
}
Community
  • 1
  • 1
Amalo
  • 772
  • 3
  • 13
  • 32
  • "I want to call a web service from my android app IntentService" - So just do it. There's no need for an `AsyncTask`, as `onHandleIntent()` already runs asynchronously. – Mike M. Nov 21 '15 at 13:22
  • Okay so how i can use the data returned by the web service? what is the similar of 'onPostExecute' method in this case?? – Amalo Nov 21 '15 at 13:23
  • One option is to use [`LocalBroadcastManager`](http://developer.android.com/intl/es/reference/android/support/v4/content/LocalBroadcastManager.html) to broadcast the results back to your Activity, or wherever you need them. – Mike M. Nov 21 '15 at 13:27

0 Answers0