Code example for Semaphore

0
		return composeOpenGeoSMS(url, report.getLatitude(),
				report.getLongitude(), payload);
	} 
 
	private class Receiver extends BroadcastReceiver {
		private Semaphore mSem = new Semaphore(0);
		private boolean mRecvRetVal = false;
		private List<PendingIntent> mPendingIntents;
 
		public boolean waitForResult(List<PendingIntent> pIntents) {
			mPendingIntents = pIntents;
			mSem.acquireUninterruptibly();
			return mRecvRetVal;
		} 
 
		@Override 
		public void onReceive(Context context, Intent intent) {
			if (getResultCode() != Activity.RESULT_OK) {
				mRecvRetVal = false;
				context.unregisterReceiver(this);
Connect your IDE to all the code out there  Get Codota for Java