Page 1 of 1

change contact value?

Posted: 07 Feb 2018 08:39
by Friend1
Hi Desmanto,


Can i change any value from my contacts using automagic? İf possible can you give an example to do this? Thanks.

Re: change contact value?

Posted: 07 Feb 2018 15:48
by Desmanto
Contact is just like alarm and calendar. You can query it, you can add it, but can't delete it yet. So if "change" means to add, yes we can.

Adding new Contact
Just use action Start Activity. I just populated all the field from autoshare. Probably there are more field available.

Element : Action - Start Activity
Action : android.intent.action.INSERT
Data MIME Type : vnd.android.cursor.dir/raw_contact
Explicit Component - Package Name : com.android.contacts
(leave the class name blank. Or you can also don't use the explicit component)
Extras : (change the second key as you need)

Code: Select all

putString("name", "Tinkerton Fifle Tat");
putString("phone", "123-456-7890");
putString("email", "test@test.com");
putString("postal", "de way street no 123");
putString("company", "elgoog, Ltd");
putString("job_title", "Board of Director");
putString("notes", "this is created using Automagic Start Activity");
After execution, you will be directed to adding contact. You should use Control UI to tap the OK button. There is no way to automagically create it in background, still need the last OK to be confirmed using Control UI. After Ok, probably you should use back() once or twice to back to the previous app (depends on your phone).

Editing Contact
There is a documentation at Android's manual to edit existing contact (adding new number to existing contact). It states that we should have the _ID and lookup_uri of the contact we wanna add. We can retrieve these 2 values from Query Content Provided. But I tried it with various key named "_ID", "lookup_uri", "lookup", it didn't open up the contact uri I put in. Seems the key has different name, and I don't know yet any way to get it. Logcat doesn't show any extras. I wish I have a way to check the extras from logcat, so I can mimic exactly the same as other app.

Deleting Contact
Android provide no method to delete the contact directly, similar to alarm and calendar. To delete it, need root, use sqlite3 to access the database stored at contact storage. But I don't know about the consequences from editing the database directly. Some phone handle the contact differently. It may corrupt it and destroy the whole database (deleting all of our contacts). So I prefer to stay away from it.

Re: change contact value?

Posted: 08 Feb 2018 13:47
by Friend1
Hi Desmanto,

Thank you very much for your suggestion. I tired Start Activity with android.intent.action.EDIT it's worked but can not to click OK button. (Not have any ID). Any other ideas to do this?

Re: change contact value?

Posted: 08 Feb 2018 14:55
by Desmanto
At mine, EDIT doesn't work, no intent found to handle it. Just use another, try click("OK") if there is. Control UI part usually need to be done by yourself, since it is usually device-specific.