Code example for Queue

Methods: size, addAll

0
this.ctx = ctx;
 
		Comparator<SMSMessage> comparator = new SMSMessageDeliveryTimeComparator();
		messageQueue = new PriorityBlockingQueue<SMSMessage>(11, comparator);
		messageQueue.addAll(messages);
	} 
 
	public static SMSDeliveryService getInstance(Context ctx)
	{ 
		if (_instance == null)
		{ 
			SMSMessageDBAdapter adapter = new SMSMessageDBAdapter(ctx);
			adapter.open();
 
			Collection<SMSMessage> c = adapter.getAllMessages();
 
			_instance = new SMSDeliveryService(ctx, c);
 
			// Start the background Delivery service 
			_instance.startBGDeliveryService();
 
			adapter.close();
 
		} 
		return _instance;
	} 
 
	private void startBGDeliveryService() 
	{ 
		Log.d(this.getClass().getName() + "startBGDeliveryService", "Starting up background SMS Delivery Service");
		if (!deliverServiceStarted)
		{ 
			if (messageQueue.size() != 0)
			{ 
				deliverServiceStarted = true;
				Intent msgIntent = new Intent(ctx, SMSDeliveryMainIntentService.class);
				ctx.startService(msgIntent);
 
Experience pair programming with AI  Get Codota for Java