Open ravindragupta90 opened 7 years ago
Hi aarsy, I am trying to convert a jCard -> vCard and then create a contact. I tried ur new link. Getting same result.
This is my code :
JCardReader reader = new JCardReader(jCard); reader.registerScribe(new AndroidCustomFieldScribe()); ContactOperations operations = new ContactOperations(mContext, accName, accType); try { VCard vcard; while ((vcard = reader.readNext()) != null) { operations.insertContact(vcard); } } finally { reader.close(); }
Any suggestions on what might be wrong?
to which account are u inserting the contacts ..Can u please provide those details as well
Looks like the issue is you are not adding contact to device native/default account name and account type. If so for most common contact-fields there will not be any issue in adding but will have issue in editing. I would say first try to find device native/default account name and type then try to add contact to that account name.
Hi @aarsy and @vikky49 , I am passing account type = 'com.sample.tron.account.MyACCOUNT' and account name = 'myId@myaccount.com'.
My account is working fine as i have used it for 2 other syncAdapters in the same app. And even in the SO link which u share to get the account. I am getting my account listed there.
The data which i shared to u was a sample not the actual. Find the actual data below..
**** Get All Registered Accounts *****
--> smtestuser1@gmail.com : com.google ,
--> ravindra.gupta@sm.com : com.sample.tron.account.MyACCOUNT,
Correct me if am wrong: If my account name and type is not valid, will the contact app show the contacts which was created from my app?
Sorry to trouble u
@aarsy I tried your example too. When we create a contact for account 'com.google' it work good. But when i tried to insert the .vcf with some other account. It is still not editable.
private void getAccountsAndShowDialog() {
AccountManager am = AccountManager.get(this);
//Since write contacts permission is already asked and GET_ACCOUNTS permission also lies
// in same permission group therefore there is no need to ask for it. It will be allowed automatically.
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
Account[] accounts = am.getAccounts();
String account_name = null;
String account_type = null;
for (Account ac : accounts) {
String acname = ac.name;
String actype = ac.type;
System.out.println("Accounts : " + acname + ", " + actype);
//get the google account
if (actype.equals("org.c99.SyncProviderDemo.account")) {
account_name = acname;
account_type = actype;
}
}
FragmentManager fragmentm = getSupportFragmentManager();
MyAlertDialog dialog = MyAlertDialog.newInstance(account_name, account_type);
dialog.show(fragmentm, "fragment_select");
}
Here u can find the demo app whose accountType is "org.c99.SyncProviderDemo.account" Kindly Share ur feedback.
Hi, I am using these classes to insert the contacts, which is working like a charm. But i am unable to edit that same contact from stock contact app, because the contacts are created like whatsapp contacts which are non editable. Is it a bug or to be handled by me? as i am new to it, i would appreciate if u share any references or sample.