Code example for ResultReceiver

Methods: send

1
	@Override 
	protected void onHandleIntent(Intent intent) {
		Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")");
 
		ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER);
		receiver.send(STATUS_RUNNING, Bundle.EMPTY);
		try { 
			String lineName = intent.getStringExtra("lineName");
			String ud = intent.getStringExtra("ud");
			String sno = intent.getStringExtra("sno");
			String hczd = intent.getStringExtra("hczd");
			 
			// 调用http 
			//String back = ServerUtilities.getGps(lineName,ud,sno,hczd); 
			String[] back = ServerUtilities.getGps(lineName,ud,sno);
		//	Log.d(TAG, back); 
			Bundle b = new Bundle();
			b.putStringArray("response", back);
			receiver.send(STATUS_FINISHED, b);
		} catch (Exception e) {
			Log.e(TAG, "服务器异常", e);
			if (receiver != null) {
				Bundle bundle = new Bundle();
				bundle.putString(Intent.EXTRA_TEXT, "服务器异常");
				receiver.send(STATUS_ERROR, bundle);
			} 
		} 
	} 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE