Message Receiver

public class AlertMessageReceiver extends BroadcastReceiver {

	public MessageReceiver() {
	}

	@Override
	public void onReceive(Context context, Intent intent) {

		int codeId = intent.getIntExtra("ERROR_CODE", -1);
		Resources res = context.getResources();
		String message = "";
		switch (codeId) {
		case ErrorCode.NETWORK_ERROR:
			message = res.getString(R.string.network_timeout_error);
			break;
		case ErrorCode.NETWORK_UNAVAILABLE:
			message = res.getString(R.string.network_no_found);
			break;
		case ErrorCode.JSON_DATA_ERROR:
			message = res.getString(R.string.data_parser_error);
			break;
		default:
			message = res.getString(R.string.unknow_error);
			break;
		}
		Toast.makeText(context, message, Toast.LENGTH_LONG).show();

	}
}

 

你可能感兴趣的:(String,Class,resources)