Code example for Semaphore

Methods: acquireUninterruptibly

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);
				mSem.release();
				return; 
			} 
 
			// Fix for a potential null object here 
			if (mPendingIntents != null) {
				mPendingIntents.remove(mPendingIntents.size() - 1);