Automatically import contacts from a VCF file

Automatically import contacts from a VCF file

Hi all,

Zebra TC75 android

 

I'm trying to import contacts into the devices automatically.

I can copy a vcf file to sd as package, if I open the file manually in the file explorer it'll ask if I want to import the contacts.

But if I open the file through a script it tries to load them through PDF viewer.

 

If I open the "Contacts" app and click import/export -> import from SD card. everything works as expected.

 

What I want is to have a pre/post install script which will update the contacts on the device automatically. But currently the closet to getting what I want is to open contacts, and send a message to the user to import the contacts file.

 

<code>start activity com.android.contacts/com.android.contacts.activites.PeopleActivity

showmessagebox "Please use the menu in the top right hand corner, press import/export, and click \"Import from Storage\""</code>

 

This there an intent I can send which will open the import command with no user intervention?

I've looked through the source code and can see the action "com/android.contacts.vcard.ImportRequest" but nothing happens when I try sending it as an intent, am I missing an instruction, as you can import from sdcard or simcard?

<code>sendintent -a "intent://com.andriod.contacts#Intent;action=com.android.contacts.vard.ImportRequest;end"</code>

 

Thanks for any ideas

Gary

10 Answers

Order By:   Standard | Newest | Votes
SMod@Soti | posted this 14 August 2018

Hi Gary,

 

Currently, there is no way to automate this process as user intervention is required when .vcf file is transferred to the device.

 

There has already been multiple feature requests submitted for this feature to be included in MobiControl and it is something our Android team is considering to add to the future versions of MobiControl. However, I would recommend you to log a case with technical support here: https://www.soti.net/services/log-a-case/ and submit a feature request so that it can be re-prioritized.

 

Please message me the case number once you create a new Feature request for this.

 

Thanks

 

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | soti.net |

 

  • 0
  • 0
Gary | posted this 14 August 2018

Thanks for that.

and....

Thank you for submitting your issue to us online.
A SOTI Inc Technical Support Engineer will respond to you shortly.

Case: C00264269

  • 0
  • 0
SMod@Soti | posted this 14 August 2018

Hi Gary,

Thank you for the details.

Even though having a dedicated payload in MobiControl will be the best way address this use case but upon further investigation, I found that SOTI did create an Android application (Contacts_Import.apk) a while ago to import contacts from the *.vcf file automatically.

Since this app was developed a while ago, please test it on couple devices in test environment before you run it in the production environment. 

Please follow the following steps:

Create a new package in the MobiControl Package Builder.

Add a post-install script to the package and it should contain two commands: sleep and uninstall. 
The post-install script command will look something like:

sleep 60

uninstall cgy.rgy.xpi

Sleep command will postpone execution of the next command line for specified number of seconds.
This will allow the VCF import APK (Contacts_Import.apk) to finish contact import before it's removed.

For the uninstall script the appID is an ID of the Contacts_Import.apk on the handset.

In the Add Files step please click Add button and select "Add Android APK...". 
Browse to the folder with Contacts_Import.apk and add it to the package. 
On the "Android Application File Attributes" window make sure that "Automatically Run Activity after install" is selected.

Click OK, leave all other options default and build the package. 
Add this package to the profile and test it in your test environment on couple devices.
You should run this only if the contacts.vcf file was synchronized successfully to the Downloads folder on the devices otherwise the contact import will fail due to the missing vcf file.

You can download the Contacts_Import.apk from here (link expires after 30 days)

Please note the following requirements:

1. The contacts file must be named “Contacts.vcf”
2. Sync this file down to the device using file sync to the Download folder (the folder must specifically be called download) on the device’s storage, if folder doesn’t exist please create it.
NOTE: If the device is in lockdown, please add the process “launch://cgy.rgy.xpi” to the lockdown.


Please let me know if that works for you.

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | soti.net |

 

  • 0
  • 0
Gary | posted this 14 August 2018

Before I test this, just want to clarify the uninstall part of the script

 

"uninstall cgy.rgy.xpi"

 

is cgy.rgy.xpi the actual appID, or could that be different on a per device biases?

 

Gary

  • 0
  • 0
SMod@Soti | posted this 14 August 2018

That should be the actual appID of the Contact_import application

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | soti.net |

 

  • 0
  • 0
Gary | posted this 14 August 2018

Hi,

 

No luck I'm afraid.

 

Does the vcf need to have a certain filename/location?

 

I adjusted the script not to uninstall so that I could test it manually. Clicking on the app shortcut in the menu seems to do nothing, no error messages either.

Just to make sure my vcf wasn't corrupted I imported them manually and that was fine.

 

Zebra TC75

Android Version: 5.1.1

 

Gary

  • 0
  • 0
SMod@Soti | posted this 15 August 2018

Can you please try making the following changes:

1. Name the file “Contacts.vcf”
2. Sync this file down to the device using file sync to the Download folder (the folder must specifically be called download) on the device’s storage, if folder doesn’t exist please create it.
3. Now deploy the package with Contacts_Import.apk app
NOTE: If the device is in lockdown, please add the process “launch://cgy.rgy.xpi” to the lockdown.

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | soti.net |

 

  • 0
  • 0
Gary | posted this 15 August 2018

Hi thanks, 

the import_contacts.apk worked.

 

But there is still a "OK/Cancel" dialog that needs to be manually clicked. but it is a lot closer to being what I wanted. 

And as the message box is in the way of the user, I can expect a good percentage will click "OK".

 

Gary

  • 0
  • 0
SMod@Soti | posted this 15 August 2018

Hi Gary,

 

I'm glad it worked for you. I believe the prompt that shows up is due to change in permissions with different Android versions. I will still try to test if there is a way around it.

 

Thanks

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | soti.net |

 

  • 0
  • 0
Gary | posted this 15 August 2018

Hi,

 

after a bit more testing, I'm finding that the timeout/sleep delay doesn't wait for the "OK/Cancel" to bit clicked and removes the app (and the dialog box) if left too long.

 

My work around is to remove the delay, and when I need to do an update, revoke the profile, and reinstate it when I have a new Contacts.vcf to add.

 

But, this is still a better position than I was in before I had this import_contacts.akp

 

Gary

  • 0
  • 0

Give us your feedback
Give us your feedback
Feedback