Solution: Create Contact

labirio

New Member
Licensed User
Longtime User
Hi, I need to make a simple application that add a prefix number before dialing particular contacts in a specific group...
I tried to find in all forum posts if anyone has my same problem ... I cannot handle contacts details with standard libraries on Samsung Galaxy S or Galaxy mini (0 records result). Only miscutils lib can do it but doesn't distinguish from internal, skype or other contacts. Actually i can't find a solution to filter them. Could you help me?

Sorry for english mistakes... :sign0013:

Luca
 

droman

Member
Licensed User
Longtime User
I can add a photo to a contact with this lib?

Sorry for my english... again
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
Let me post here also - i cannot get all the contacts by GetAll on a real device with big phonebook. On real device only 5 contacts are got by GetAll function. :-(
On emulators with just new added contacts - no problem, all contacts are got well.

What can be problem ?
 
Last edited:
D

Deleted member 103

Guest
Hi optimist,

Thanks for this library.
Can you add this feature?

B4X:
public Boolean DeleteContactById(String id)
  {
     ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
     ops.add(ContentProviderOperation.newDelete(RawContacts.CONTENT_URI)
         .withSelection(RawContacts._ID + " = ?", new String[]{id})
         .build());
      ContentResolver cr = this.m_ba.context.getContentResolver();
        try {
            cr.applyBatch(ContactsContract.AUTHORITY, ops);
        }
        catch (Exception e)
         {
           return Boolean.valueOf(false);
         }
       return Boolean.valueOf(true);
     }

Ciao,
Filippo
 

optimist

Member
Licensed User
Longtime User
Thank you Filippo, i will do this these weekend.

Regarding the problem to get ALL contacts:
Can anyone provide an cellphone for testing purposes? I would need it for 2-3 days in Germany near Cologne.
 
D

Deleted member 103

Guest
Hi optimist,

es ist immer besser die neue Version in dem erste Posting(Thread) zu kopieren bzw. zu ersetzten.

It is always better the new version in the first post (thread) to copy or to replace.

Ciao,
Filippo
 

peacemaker

Expert
Licensed User
Longtime User
Any possibility to update a selected contact ? Edit Notes, for ex.
 

peacemaker

Expert
Licensed User
Longtime User
Actually, if Name is of an existing contact - createContactEntry2 updates the contact well :), but.... for updating all fields must be preset from this existing contact, but Website, Organization, Homeaddress, Workaddress...no idea if they are got (if exist) to be sure in re-writing them.
Each createContactEntry2 with various NOTES string - adds this Notes to previous Notes :)

But after creating - manual editing the contact is impossible - force close of "android.process.core" (2.2 emulator, 2.3 device is OK). Manual deleting is OK.
So - partially work as needed (can create and edit), but....with some issues.

UPD: contact with the same name is updated by createContactEntry2 in Android 2.2. v.2.3 adds a cloned new contact :-(

So, the resume: now no universal possibility to update the contact :-(((
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
Hm, i see that UPDATE is CREATE + DELETE ALL OLD ones.
But after creation of the contact - DeleteContactById of this micsUtil - does not work (emulator 2.3.3), but DeleteContactById of fgContacts - works !
 
Last edited:

SirGu

New Member
Licensed User
Longtime User
It would be really fantastic if complete name and birthday could be reported in getcontactbyId.

Could be possible?
 

BobsYourUncle

Member
Licensed User
Longtime User
Hi Optimist - just wanted to say thanks for your work on the miscUtils library. It's a very useful library! :sign0098:
(Also thanks to everyone else who has contributed).
 

NJDude

Expert
Licensed User
Longtime User
I found a couple of things:

1- Like I mentioned on a previous post on this thread, one of the tooltips is in German (GetContactsByID).

2- There's a misspelling, "DeleteAllConcacts" instead of "DeleteAllContacts".

I need to play more with it. ;)
 

peacemaker

Expert
Licensed User
Longtime User
Sorry to posting here, but maybe authors of CONTACT related libs can help me with this ?
 

Gary Miyakawa

Active Member
Licensed User
Longtime User
Optimist,

Very useful library! I needed to add some contacts for a project and the adding worked well.

I have a questions...

When the library adds a contact, it goes into (on my Galaxy Tab 2) into the "device" contacts list. Is there anyway to force it to another list ? I think this is where some people have been having trouble with the "get all" function. I can get around this by doing a "GetAll" with Contacts2 function from Phone but just wondered if there is a way to keep it within one library.

Thanks for your effort, it's of great help!

Gary M
 

Gary Miyakawa

Active Member
Licensed User
Longtime User
Optimist (et al),

I'm struggling try to delete a contact. I was able to create a contact (Yeah).. but now, I need to be able to delete one.

My code looks like this:

B4X:
Dim mu As miscUtil
Dim b As Boolean

mu.Initialize
b = mu.DeleteContactById("A")

My contact name is A

I get a "true" back from the delete but when I look in the contacts list, it's still there.

Any suggestions ?

Thanks,

Gary M
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Id should be a number

Using this, can we get the address of a contact? The current api doesn't.
 

binhtquang

Member
Licensed User
Longtime User
Is it possible to somehow incorporate this to save to contacts from a vCard scanned from a QR Code?
 

madSac

Active Member
Licensed User
Longtime User
I am still getting error to initialize the map
B4X:
m.createContactEntry2("test",Null,phones,mails,"string","string","",Null,Null)

error is
B4X:
LogCat connected to: 0123456789ABCDEF
--------- beginning of /dev/log/main


** Activity (main) Pause, UserClosed = true **
** Service (createcontact) Start **
createcontact_madtest (java line: 319)


java.lang.RuntimeException: Object should first be initialized (Map).
   at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:45)
   at anywheresoftware.b4a.objects.collections.Map.GetValueAt(Map.java:104)
   at lilivel.b4a.miscUtil.miscUtil.createContactEntry2(miscUtil.java:125)
   ...

i am using this code in a service.
 
Top