I created a WebService
class that handles multiple different requests to a web service, this class Broadcast's and intent with a different key
depending on what method was originally called in the WebService
class. I'm stuck on how to properly handle this on the WebServiceReceiver
...
Here's the important part from the WebService
:
//Broadcast the intent with data received from service call.
broadcastIntent.putExtra(broadcastIntentKeyName, response.toString());
sendBroadcast(broadcastIntent);
Here's my onReceive
:
public class WebServiceReceiver extends BroadcastReceiver
{
public WebServiceReceiver() {}
@Override
public void onReceive(Context context, Intent intent) {
Debug.waitForDebugger();
//NOTE: Not sure if i'm approaching this the right way, sure doesn't seem like it...
//Its possible that some of these will be NULL.
String GetRequestForRouteWithDriverId_DATA = intent.getStringExtra("Helper_GetRequestForRouteWithDriverId");
String StoreDataInServer_DATA = intent.getStringExtra("Helper_StoreDataInServer");
String SubmitDriverRouteData_DATA = intent.getStringExtra("Helper_SubmitDriverRouteData");
MainActivity.getInstance().updatetextViewControl(GetRequestForRouteWithDriverId_DATA);
}
}
What I have does work, But like I mentioned in my code comment, it doesn't feel like its the proper way.
Is there a better way to approach this? I simply want to re-use this onReceive
to handle all WebService
Broadcasts.