//Checks to see if there is already a conversation between the device and emulator
        private Conversation _GetConversation()
        {
            if (activeConversation == null)
            {
                LayerQuery query = LayerQuery.InvokeBuilder(Java.Lang.Class.FromType(typeof(Conversation)))
                                   .Predicate(new Predicate(Conversation.Property.Participants,
                                                            Predicate.Operator.EqualTo, new Java.Util.ArrayList(MainActivity.GetAllParticipants())))
                                   .SortDescriptor(new SortDescriptor(Conversation.Property.CreatedAt,
                                                                      SortDescriptor.Order.Descending))
                                   .Build();

                IList results = layerClient.ExecuteQuery(query, LayerQuery.ResultType.Objects);
                if (results != null && results.Count > 0)
                {
                    return(results[0] as Conversation);
                }
            }

            //Returns the active conversation (which is null by default)
            return(activeConversation);
        }
            /**
             * Returns the current maximum Message position within the given Conversation, or
             * Long.MIN_VALUE if no messages are found.
             *
             * @param conversationId Conversation whose maximum Message position to return.
             * @return the current maximum Message position or Long.MIN_VALUE.
             */
            private long GetMaxPosition(Uri conversationId)
            {
                LayerClient layerClient = App.GetLayerClient();

                LayerQuery query = LayerQuery.InvokeBuilder(Java.Lang.Class.FromType(typeof(IMessage)))
                                   .Predicate(new Predicate(MessageProperty.Conversation, Predicate.Operator.EqualTo, conversationId))
                                   .SortDescriptor(new SortDescriptor(MessageProperty.Position, SortDescriptor.Order.Descending))
                                   .Limit(1)
                                   .Build();

                IList <IQueryable> results = layerClient.ExecuteQueryForObjects(query);

                if (results.Count == 0)
                {
                    return(long.MinValue);
                }
                var message = results[0] as IMessage;

                if (message == null)
                {
                    return(long.MinValue);
                }
                return(message.Position);
            }