Пример #1
0
 void FillContacts()
 {
     var uri = ContactsContract.CommonDataKinds.Phone.ContentUri;
     string[] projection = {
        ContactsContract.CommonDataKinds.Phone.Number,
        ContactsContract.Contacts.InterfaceConsts.DisplayName,
        ContactsContract.Contacts.InterfaceConsts.PhotoId
       };
     //select id,DisplayName,PhotoId where id=1
     var loader = new CursorLoader(this, uri, projection, null, null, null);
     var cursor = (ICursor)loader.LoadInBackground();
     List<Contact> contactList = new List<Contact>();
     if (cursor.MoveToFirst())
     {
         do
         {
             contactList.Add(
             new Contact(cursor.GetString(cursor.GetColumnIndex(projection[0])),
                  cursor.GetString(cursor.GetColumnIndex(projection[1])),
                cursor.GetString(cursor.GetColumnIndex(projection[2]))
            )
            );
         } while (cursor.MoveToNext());
     }
     string items = "";
     foreach ( Contact c in contactList)
     {
         items += c.DisplayName + "," + c.Number + "," + c.PhotoId;
     }
     textView1.Text = items;
 }
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.HomeScreen);
            listView = FindViewById<ListView>(Resource.Id.List);

            string[] projection = new string[] { VegetableProvider.InterfaceConsts.Id, VegetableProvider.InterfaceConsts.Name };
            string[] fromColumns = new string[] { VegetableProvider.InterfaceConsts.Name };
            int[] toControlIds = new int[] { Android.Resource.Id.Text1 };

            // ManagedQuery is deprecated in Honeycomb (3.0, API11)
            cursor = ManagedQuery(VegetableProvider.CONTENT_URI, projection, null, null, null);
            
            // ContentResolver requires you to close the query yourself
            //cursor = ContentResolver.Query(VegetableProvider.CONTENT_URI, projection, null, null, null);
            //StartManagingCursor(cursor);

            // CursorLoader introduced in Honeycomb (3.0, API11)
            var loader = new CursorLoader(this,
                VegetableProvider.CONTENT_URI, projection, null, null, null);
            cursor = (ICursor)loader.LoadInBackground();

            // create a SimpleCursorAdapter
            adapter = new SimpleCursorAdapter(this, Android.Resource.Layout.SimpleListItem1, cursor, 
                fromColumns, toControlIds);

            listView.Adapter = adapter;
            
            listView.ItemClick += OnListItemClick;
        }
        void FillContacts()
        {
            var uri = ContactsContract.Contacts.ContentUri;

            string[] projection =
            {
                ContactsContract.Contacts.InterfaceConsts.Id,
                ContactsContract.Contacts.InterfaceConsts.DisplayName,
                ContactsContract.Contacts.InterfaceConsts.PhotoId
            };

            var loader = new Android.Content.CursorLoader(activity, uri, projection, null, null, null);

            using (var cursor = (ICursor)loader.LoadInBackground()) {
                contactList = new List <Contact> ();
                if (cursor.MoveToFirst())
                {
                    do
                    {
                        contactList.Add(new Contact {
                            Id          = cursor.GetLong(cursor.GetColumnIndex(projection [0])),
                            DisplayName = cursor.GetString(cursor.GetColumnIndex(projection [1])),
                            PhotoId     = cursor.GetString(cursor.GetColumnIndex(projection [2]))
                        });
                    }while (cursor.MoveToNext());
                }
            }
        }
		public static List<Song> LoadSongs (Activity context)
		{
			var uri = MediaStore.Audio.Media.ExternalContentUri;
			String selection = MediaStore.Audio.Media.InterfaceConsts.IsMusic + " != 0";
			string[] projection = {
				MediaStore.Audio.Media.InterfaceConsts.Id,
				MediaStore.Audio.Albums.InterfaceConsts.AlbumId,
				MediaStore.Audio.Media.InterfaceConsts.Title,
				MediaStore.Audio.Media.InterfaceConsts.Artist,
			};

			var loader = new CursorLoader (context, uri, projection, selection, null, null);
			var cursor = (ICursor)loader.LoadInBackground ();

			List<Song> songs = new List<Song> ();
			if (cursor.MoveToFirst ()) {
				do {
					songs.Add (new Song (
						cursor.GetLong (cursor.GetColumnIndex (projection [0])),
						cursor.GetLong (cursor.GetColumnIndex (projection [1])),
						cursor.GetString (cursor.GetColumnIndex (projection [2])),
						cursor.GetString (cursor.GetColumnIndex (projection [3]))
					));
				} while (cursor.MoveToNext ());
			}
			return songs;
		}
Пример #5
0
        static int PICK_CONTACT_REQUEST = 42; // The request code
        
        protected void OnActivityResult(TaskCompletionSource<ContactInfo> tcs, ActivityResultEventArgs e) //int requestCode, Android.App.Result resultCode, Intent data)
        {
            // Check which request it is that we're responding to
            if (e.requestCode == PICK_CONTACT_REQUEST)
            {
                // Make sure the request was successful
                if (e.resultCode == Android.App.Result.Ok)
                {
                    var loader = new CursorLoader(MainActivity.Instance, e.data.Data, projection, null, null, null);
                    var cursor = (Android.Database.ICursor)loader.LoadInBackground();

                    var contactList = new List<ContactInfo>();
                    if (cursor.MoveToFirst())
                    {
                        do
                        {
                            contactList.Add(GetContactInfoFromCursor(cursor));
                        } while (cursor.MoveToNext());
                    }
                    tcs.SetResult(contactList.FirstOrDefault());
                    return;
                }
            }

            tcs.SetResult(null);
        }
Пример #6
0
        private ICursor CreateCursor()
        {
            string[] columns = { MediaStore.Images.Media.InterfaceConsts.Data, MediaStore.Images.Media.InterfaceConsts.Id };

            string orderBy = MediaStore.Images.Media.InterfaceConsts.Id;

            var loader = new CursorLoader(this, MediaStore.Images.Media.ExternalContentUri, columns, null, null, orderBy + " DESC");
            var cursor = (ICursor)loader.LoadInBackground();

            return cursor;
        }
Пример #7
0
        static int PICK_CONTACT_REQUEST = 42; // The request code
        
        protected void OnActivityResult(TaskCompletionSource<ContactInfo> tcs, ActivityResultEventArgs e) //int requestCode, Android.App.Result resultCode, Intent data)
        {
            // Check which request it is that we're responding to
            if (e.requestCode == PICK_CONTACT_REQUEST)
            {
                // Make sure the request was successful
                if (e.resultCode == Android.App.Result.Ok)
                {
                    //var uri = ContactsContract.Contacts.ContentUri;
                    string[] projection = {
                       ContactsContract.Contacts.InterfaceConsts.Id,
                       ContactsContract.Contacts.InterfaceConsts.DisplayName,
                       ContactsContract.Contacts.InterfaceConsts.PhotoId,
                    };

                    var loader = new CursorLoader(MainActivity.Instance, e.data.Data, projection, null, null, null);
                    var cursor = (Android.Database.ICursor)loader.LoadInBackground();

                    var contactList = new List<ContactInfo>();
                    if (cursor.MoveToFirst())
                    {
                        do
                        {
                            var displayName = cursor.GetString(cursor.GetColumnIndex(projection[1]));
                            var nameParts = displayName.Split(' ');
                            var lastName = nameParts.Length > 1 ? nameParts[1] : null;
                            contactList.Add(new ContactInfo()
                            {
                                Id = cursor.GetLong(cursor.GetColumnIndex(projection[0])).ToString(),
                                GivenName = nameParts[0],
                                AdditionalName = null,
                                FamilyName = lastName
                            });
                        } while (cursor.MoveToNext());
                    }
                    tcs.SetResult(contactList.FirstOrDefault());
                    return;
                }
            }

            tcs.SetResult(null);
        }
Пример #8
0
        // Read back the user name and print it to the console:
        bool ReadBackName()
        {
            // Get the URI for the user's profile:
            Android.Net.Uri uri = ContactsContract.Profile.ContentUri;

            // Setup the "projection" (columns we want) for only the display name:
            string[] projection = { ContactsContract.Contacts.InterfaceConsts.DisplayName };

            // Use a CursorLoader to retrieve the user's profile data:
            CursorLoader loader = new CursorLoader (this, uri, projection, null, null, null);
            ICursor cursor = (ICursor)loader.LoadInBackground();

            // Print the user name to the console if reading back succeeds:
            if (cursor != null)
            {
                if (cursor.MoveToFirst())
                {
                    Console.WriteLine(cursor.GetString(cursor.GetColumnIndex(projection[0])));
                    return true;
                }
            }
            return false;
        }
Пример #9
0
        public System.String PhonesByUri(Uri uri)
        {
            var loader = new CursorLoader (_context, uri, null, null, null, null);
            ICursor cur;
            cur = (ICursor)loader.LoadInBackground ();

            cur.MoveToFirst();
            System.String phones="";
            int id = cur.GetInt(cur.GetColumnIndex(ContactsContract.Contacts.InterfaceConsts.Id));
            if (System.Int16.Parse(cur.GetString(cur.GetColumnIndex(ContactsContract.Contacts.InterfaceConsts.HasPhoneNumber))) > 0)
            {
                var _loader = new CursorLoader (_context, ContactsContract.CommonDataKinds.Phone.ContentUri,null,ContactsContract.CommonDataKinds.Phone.InterfaceConsts.ContactId +" = "+id,null, null);
                ICursor pCur;
                pCur = (ICursor)_loader.LoadInBackground ();
                while (pCur.MoveToNext())
                {
                    phones+=pCur.GetString(pCur.GetColumnIndex(ContactsContract.CommonDataKinds.Phone.InterfaceConsts.Data))+"\r\n";
                }
                pCur.Close();
            }
            return phones;
        }
        private void LoadSCData()
        {
            Android.Net.Uri uri;
            //
            String[] projection = {BowlingContract.BaseColumns._ID, BowlingContract.ScorecardColumns.SCORECARD_SEASONID, BowlingContract.ScorecardColumns.SCORECARD_BOWLING_DATE,
                BowlingContract.ScorecardColumns.SCORECARD_GAME1, BowlingContract.ScorecardColumns.SCORECARD_GAME2, BowlingContract.ScorecardColumns.SCORECARD_GAME3,
                BowlingContract.ScorecardColumns.SCORECARD_TOTAL, BowlingContract.ScorecardColumns.SCORECARD_AVERAGE
                };

            uri = BowlingContract.URI_TABLE;
            // CursorLoader introduced in Honeycomb (3.0, API11)
            var loader = new CursorLoader(_activity, uri, projection, null, null, null);
            var mCursor = (Android.Database.ICursor)loader.LoadInBackground();

            mScorecards = new List<Scorecard>();

            //mCursor = mContentResolver.Query(BowlingContract.URI_TABLE, projection, null, null, BowlingContract.ScorecardColumns.SCORECARD_BOWLING_DATE + " DESC");
            if (mCursor != null)
            {
                if (mCursor.MoveToFirst())
                {
                    do
                    {
                        int _id = mCursor.GetInt(mCursor.GetColumnIndex(BowlingContract.BaseColumns._ID));
                        String seasonId = mCursor.GetString(mCursor.GetColumnIndex(BowlingContract.ScorecardColumns.SCORECARD_SEASONID));
                        String bowlingDate = mCursor.GetString(mCursor.GetColumnIndex(BowlingContract.ScorecardColumns.SCORECARD_BOWLING_DATE));
                        String game1 = mCursor.GetString(mCursor.GetColumnIndex(BowlingContract.ScorecardColumns.SCORECARD_GAME1));
                        String game2 = mCursor.GetString(mCursor.GetColumnIndex(BowlingContract.ScorecardColumns.SCORECARD_GAME2));
                        String game3 = mCursor.GetString(mCursor.GetColumnIndex(BowlingContract.ScorecardColumns.SCORECARD_GAME3));
                        String seriesTotal = mCursor.GetString(mCursor.GetColumnIndex(BowlingContract.ScorecardColumns.SCORECARD_TOTAL));
                        String seriesAverage = mCursor.GetString(mCursor.GetColumnIndex(BowlingContract.ScorecardColumns.SCORECARD_AVERAGE));
                        //
                        Scorecard scorecard = new Scorecard(_id, seasonId, bowlingDate, game1, game2, game3, seriesTotal, seriesAverage);
                        mScorecards.Add(scorecard);
                    } while (mCursor.MoveToNext());

                }
            }
        }
		private string GetPathToImage(Android.Net.Uri uri)
		{
			string doc_id = "";
			try{
				using (var c1 = Application.Context.ContentResolver.Query (uri, null, null, null, null)) {
					c1.MoveToFirst ();
					String document_id = c1.GetString (0);
					doc_id = document_id.Substring (document_id.LastIndexOf (":") + 1);
				}
			}catch{
				Log.Debug ("GetPathToImage","Excepcion! El content es File");
				Android.Content.Context context = Android.App.Application.Context;
				try{
					String[] proj = { MediaStore.MediaColumns.Data };
					Log.Debug ("GetPathToImage","Y la URI? "+uri.ToString());

					//	var c1 = context.ContentResolver.Query (uri, proj, null, null, null)
					var loader = new CursorLoader (context, uri, proj, null, null, null);
					var c1 = (ICursor)loader.LoadInBackground();

					if(c1==null){
						Log.Debug ("GetPathToImage","Sigue siendo nulo-");
					}

					c1.MoveToFirst ();
					Log.Debug ("GetPathToImage","Pasamos?");

					String document_id = c1.GetString (0);
					doc_id = document_id.Substring (document_id.LastIndexOf (":") + 1);
					Log.Debug ("GetPathToImage","Y bien? "+doc_id);

				}
				catch(Exception ex){
					Log.Debug ("GetPathToImage","Excepcion! "+ex);
				}
			}

			string path = null;
			// The projection contains the columns we want to return in our query.
			string selection = Android.Provider.MediaStore.Images.Media.InterfaceConsts.Id + " =? ";
			using (var cursor = Application.Context.ContentResolver.Query(Android.Provider.MediaStore.Images.Media.ExternalContentUri, null, selection, new string[] {doc_id}, null))
			{
				if (cursor == null) return path;
				var columnIndex = cursor.GetColumnIndexOrThrow(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data);
				cursor.MoveToFirst();
				path = cursor.GetString(columnIndex);
				//cursor.Close ();
			}
			return path;
		}
Пример #12
0
        public static string GetContactIDFromLookupKey(Context ctx, string lookupKey)
        {
            var loader = new CursorLoader(ctx, ContactsContract.Contacts.ContentUri,
                new string[] { ContactsContract.Contacts.InterfaceConsts.Id },
                ContactsContract.Contacts.InterfaceConsts.LookupKey + " = ?",
                new string[] { lookupKey },
                null);
            var cursor = (ICursor)loader.LoadInBackground();

            string id = null;
            if (cursor.MoveToFirst())
            {
                id = cursor.GetString(0);
            }
            cursor.Close();

            return id;
        }
Пример #13
0
        public static IEnumerable<AndroidContact> GetContactList(Activity context)
        {
            string[] projection = { ContactsContract.Contacts.InterfaceConsts.Id,
                                      ContactsContract.Contacts.InterfaceConsts.DisplayName,
                                      ContactsContract.Contacts.InterfaceConsts.PhotoThumbnailUri };

            var loader = new CursorLoader(context, ContactsContract.Contacts.ContentUri, projection, null, null, null);
            var cursor = (ICursor)loader.LoadInBackground();

            if (cursor.MoveToFirst())
            {
                do
                {
                    var c = new AndroidContact();
                    c.Id = cursor.GetString(0);
                    c.DisplayName = cursor.GetString(1);

                    var uri = cursor.GetString(2);
                    if (uri != null)
                        c.PhotoThumbnailUri = Android.Net.Uri.Parse(uri);

                    yield return c;
                } while (cursor.MoveToNext());
            }

            cursor.Close();
        }
 // Convert a gallery URI to a regular file path
 private string GetPath(Android.Net.Uri uri)
 {
     string[] projection = new string[] { MediaStore.MediaColumns.Data };
     CursorLoader loader = new CursorLoader(Activity, uri, projection, null, null, null);
     ICursor cursor = (ICursor)loader.LoadInBackground();
     int column_index = cursor.GetColumnIndexOrThrow(MediaStore.MediaColumns.Data);
     cursor.MoveToFirst();
     return cursor.GetString(column_index);
 }
 private String GetRealPathFromUri(Context context, Uri uri)
 {
     String[] proj = { MediaStore.Images.ImageColumns.Data };
     CursorLoader loader = new CursorLoader(context, uri, proj, null, null, null);
     ICursor cursor = (ICursor)loader.LoadInBackground();
     int columnIndex = cursor.GetColumnIndexOrThrow(MediaStore.Images.ImageColumns.Data);
     cursor.MoveToFirst();
     String result = cursor.GetString(columnIndex);
     cursor.Close();
     return result;
 }
Пример #16
0
 private void CreateLoader()
 {
     string[] columns = { MediaStore.Images.Media.InterfaceConsts.Data, MediaStore.Images.Media.InterfaceConsts.Id };
     string orderBy = MediaStore.Images.Media.InterfaceConsts.Id;
     _loader = new CursorLoader(_ctx, MediaStore.Images.Media.ExternalContentUri, columns, null, null, orderBy + " DESC");
 }
Пример #17
0
        public Uri[] GetContactsUriByName(System.String selname,bool ignorecase)
        {
            selname = selname.Replace ("'", "''");
            string _linq1 = System.String.Concat (ContactsContract.Contacts.InterfaceConsts.DisplayName, " LIKE '", selname, "'");
            string _linq2 = System.String.Concat ("UPPER(", ContactsContract.Contacts.InterfaceConsts.DisplayName, ") LIKE UPPER('", selname, "')");
            var loader = new CursorLoader (_context, ContactsContract.Contacts.ContentUri, null, (!ignorecase) ? (_linq1) : (_linq2), null, null);

                ICursor cur;
                cur = (ICursor)loader.LoadInBackground ();

                Uri[] contactsUri = new Uri[cur.Count];

                if (cur.MoveToFirst ()) {
                    int c = 0;
                    do {
                        System.String lookupKey = cur.GetString (cur.GetColumnIndex (ContactsContract.Contacts.InterfaceConsts.LookupKey));
                        Uri uri = Uri.WithAppendedPath (ContactsContract.Contacts.ContentLookupUri, lookupKey);
                        contactsUri [c] = uri;
                        c++;
                    } while(cur.MoveToNext ());
                }
                cur.Close ();
            return contactsUri;
        }
Пример #18
0
        void FillContacts()
        {
            var uri = ContactsContract.CommonDataKinds.Phone.ContentUri;

            string[] projection = {
                ContactsContract.CommonDataKinds.Phone.InterfaceConsts.ContactId,
                ContactsContract.Contacts.InterfaceConsts.DisplayName,
                ContactsContract.Contacts.InterfaceConsts.PhotoThumbnailUri,
                ContactsContract.CommonDataKinds.Phone.Number,
                ContactsContract.CommonDataKinds.Phone.NormalizedNumber
            };

            // Build query statement
            string selection = ContactsContract.Contacts.InterfaceConsts.HasPhoneNumber + "= ?";
            string[] selectionArgs = { "1" };
            string order = ContactsContract.Contacts.InterfaceConsts.Starred + " DESC";
            order += ", " + ContactsContract.CommonDataKinds.Phone.InterfaceConsts.ContactId;

            // Load query results
            var loader = new CursorLoader (_activity, uri, projection, selection, selectionArgs, order);
            var cursor = (ICursor)loader.LoadInBackground ();

            _contactList = new List<Contact> ();

            if (cursor.MoveToFirst ())
            {
                do {
                    _contactList.Add(new Contact{
                        Id = cursor.GetLong(cursor.GetColumnIndex(projection[0])),
                        DisplayName = cursor.GetString(cursor.GetColumnIndex(projection[1])),
                        PhotoThumbnailId = cursor.GetString(cursor.GetColumnIndex(projection[2])),
                        Number = cursor.GetString(cursor.GetColumnIndex(projection[3])),
                        NormalizedNumber = cursor.GetString(cursor.GetColumnIndex(projection[4]))

                    });
                } while (cursor.MoveToNext ());
            }
        }
Пример #19
0
        public System.String NameByUri(Uri uri)
        {
            var loader = new CursorLoader (_context, uri, null, null, null, null);
            ICursor cur;
            cur = (ICursor)loader.LoadInBackground();

            cur.MoveToFirst();
            return cur.GetString(cur.GetColumnIndex(ContactsContract.Contacts.InterfaceConsts.DisplayName));
        }
Пример #20
0
 public int IdByUri(Uri uri)
 {
     var loader = new CursorLoader (_context, uri, null, null, null, null);
     ICursor cur;
     cur = (ICursor)loader.LoadInBackground();
     cur.MoveToFirst();
     return cur.GetInt(cur.GetColumnIndex(ContactsContract.Contacts.InterfaceConsts.Id));
 }
Пример #21
0
        public Uri[] GetContactUrisByPhone(System.String phone)
        {
            Uri contactUri = Uri.WithAppendedPath(ContactsContract.PhoneLookup.ContentFilterUri, Uri.Encode(phone));

            var loader = new CursorLoader (_context, contactUri, null, null, null, null);
            ICursor cur;
            cur = (ICursor)loader.LoadInBackground();

            if((cur!=null)&(cur.Count>0))
                    {
                        Uri[] contactsUri=new Uri[cur.Count];

                        try {
                            if (cur.MoveToFirst())
                            {
                                int c=0;
                                do {
                                    System.String lookupKey = cur.GetString(cur.GetColumnIndex(ContactsContract.Contacts.InterfaceConsts.LookupKey));
                                    Uri uri = Uri.WithAppendedPath(ContactsContract.Contacts.ContentLookupUri, lookupKey);
                                    contactsUri[c]=uri;
                                    c++;
                                    } while(cur.MoveToNext());
                            }
                        } catch (System.Exception e) {
                            Log.Error("xxx",e.Message);
                        }
                        cur.Close();
                        return contactsUri;
                    }
                 	else
                    {
                        cur.Close();
                        return null;
                    }
        }
        /*
         * Fill list with message data from user Inbox.
         * */
        public static void Fill_With_Inbox_Data(Activity context,ListView listView)
        {
            Pay_SMS_Main psm=new Pay_SMS_Main();

                update_inbox_messages = true;
                List<String> items=new List<String>();
                bool valid_body_check=false;
                String smsFilteredBody="";
                String[] smsTimePaying= new string[5];

                String[] projection = new String[]{ "address", "body","date" };
                CursorLoader loader=new CursorLoader(context);
                try{
                    //slaže podatke obrnutim redom,tj od najstarijeg do najmlađeg tako da kad dodajem novi podatak na kraj da bude poredano
                    loader = new CursorLoader( context,Android.Net.Uri.Parse ("content://sms/inbox"), projection, null, null, null);
                }catch(Exception e){
                    Log.Debug ("Problem kod loadera",e.ToString ());
                }
                ICursor  cursor =  (ICursor)loader.LoadInBackground ();

                if (cursor.MoveToFirst ()) { // must check the result to prevent exception
                    do {
                        try {
                            //Ako je broj iz datoteke Zone_Numbers_Assets, odnosno ako je broj iz raspona dozvoljenih
                            if (psm.CheckSMSNumbers(cursor.GetString (cursor.GetColumnIndexOrThrow (projection [0]))))
                            {
                                String smsSender = cursor.GetString (cursor.GetColumnIndexOrThrow (projection [0]));
                                String smsBody = cursor.GetString (cursor.GetColumnIndexOrThrow (projection [1]));
                                String smsTime = cursor.GetString (cursor.GetColumnIndexOrThrow (projection [2]));
                                long smsTimeLong=long.Parse (smsTime);
                                String smsDate=psm.ConvertDateFromMillseconds (smsTimeLong);
                                smsTime=psm.ConvertTimeFromMillseconds (smsTimeLong);

                            try{
                                var tuple=ParseSMS.ParseSMSbody (smsBody);
                                valid_body_check = tuple.Item1; //bool true or false
                                smsFilteredBody = tuple.Item2; // car registration
                                smsTimePaying=tuple.Item3.Split ('.');// car_time
                            }catch(Exception e){
                                Log.Debug ("Greska prilikom filtriranja sms poruke.",e.ToString ());
                            }
                            //check if sms body pass validation
                            if(valid_body_check){
                                String msgData = psm.MessageDisplay (smsSender, smsFilteredBody,smsTime,smsTimePaying[0],smsDate);
                                items.Add (msgData);
                            }

                            }
                        } catch (Exception e) {
                            Log.Debug ("UCITAVANJE SMS-a u Pay_SMS_Main", e.ToString ());
                        }
                    } while (cursor.MoveToNext ());
                } else { // empty box, no SMS
                    cursor.Close ();
                }
                //okrecem podatke u descending nacin,tako da je najnoviji podatak na pocetku
                items.Reverse ();
                DeleteHistory ();
                using(StreamWriter writer = new StreamWriter(message_Data)){

                    foreach(String data in items ){
                        writer.Write (data+"\n");
                    };
                }

                try{
                    FillListWithData(items,context,listView);
                }catch(NullReferenceException e){
                    Log.Debug ("FillListWithData:U ucitavanju inboxa",	e.ToString ());
                    }

                Enable_message_update=false;
        }
Пример #23
0
        protected override void Run()
        {
            Looper.Prepare();
            var options = new Options ();

            var loader = new CursorLoader (Application.Context, ContactsContract.Contacts.ContentUri, null, null, null, null);

            ICursor cur;
            cur = (ICursor)loader.LoadInBackground ();

            cur.MoveToFirst ();

            while (cur.MoveToNext () && !_mFinished)
            {
                SearchDublicate (cur, options);
                base.Run ();
            }

            Message.Obtain(_mhandler,(int)MessageType.Finally).SendToTarget();
        }
Пример #24
0
        protected static Contact GetContact(Context context, string selection = null, string[] selectionArgs = null)
        {
            var contact = new Contact() ;

            var uri = ContactsContract.CommonDataKinds.Phone.ContentUri;

            string[] projection = {
                ContactsContract.CommonDataKinds.Phone.InterfaceConsts.ContactId,
                ContactsContract.Contacts.InterfaceConsts.DisplayName,
                ContactsContract.Contacts.InterfaceConsts.PhotoThumbnailUri,
                ContactsContract.CommonDataKinds.Phone.Number,
                ContactsContract.CommonDataKinds.Phone.NormalizedNumber
            };

            // Load query results
            var loader = new CursorLoader (context, uri, projection, selection, selectionArgs, null);
            var cursor = (ICursor)loader.LoadInBackground ();

            if (cursor.MoveToFirst ()) {
                contact = new Contact {
                    Id = cursor.GetLong (cursor.GetColumnIndex (projection [0])),
                    DisplayName = cursor.GetString (cursor.GetColumnIndex (projection [1])),
                    PhotoThumbnailId = cursor.GetString (cursor.GetColumnIndex (projection [2])),
                    Number = cursor.GetString (cursor.GetColumnIndex (projection [3])),
                    NormalizedNumber = cursor.GetString (cursor.GetColumnIndex (projection [4]))
                    };
            }

            return contact;
        }