change contact value?

Post your questions and help other users.

Moderator: Martin

Post Reply
Friend1
Posts: 50
Joined: 03 May 2017 06:00

change contact value?

Post by Friend1 » 07 Feb 2018 08:39

Hi Desmanto,


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

User avatar
Desmanto
Posts: 2177
Joined: 21 Jul 2017 17:50

Re: change contact value?

Post by Desmanto » 07 Feb 2018 15:48

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190829, Pie 9.0, Rooted.

Friend1
Posts: 50
Joined: 03 May 2017 06:00

Re: change contact value?

Post by Friend1 » 08 Feb 2018 13:47

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?

User avatar
Desmanto
Posts: 2177
Joined: 21 Jul 2017 17:50

Re: change contact value?

Post by Desmanto » 08 Feb 2018 14:55

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190829, Pie 9.0, Rooted.

Post Reply