Samsung galaxy S4 and some devices are only supporting Structured postal while using Intent Action_Insert
ArrayList<ContentValues> data = new ArrayList<ContentValues>();
...
ContentValues name = new ContentValues();
name.put(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE);
name.put(StructuredPostal.STREET, bundle.getString(StructuredPostal.STREET));
name.put(StructuredPostal.CITY, bundle.getString(StructuredPostal.CITY));
name.put(StructuredPostal.REGION, bundle.getString(StructuredPostal.REGION));
name.put(StructuredPostal.NEIGHBORHOOD, bundle.getString(StructuredPostal.NEIGHBORHOOD));
name.put(StructuredPostal.POSTCODE, bundle.getString(StructuredPostal.POSTCODE));
name.put(StructuredPostal.COUNTRY, bundle.getString(StructuredPostal.COUNTRY));
data.add(name);
Intent intent = new Intent(Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI);
intent.putExtra(ContactsContract.Intents.Insert.NAME, contactName);
if(android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.HONEYCOMB)
intent.putParcelableArrayListExtra(Insert.DATA, data);
else
intent.putExtra(ContactsContract.Intents.Insert.POSTAL, address);
Now for Galaxy S3 which runs on 4.2 doesn't support Structured Address and not showing the address using the above code.
So How do I find if a device supports structured postal address so that I can provide support for both?
Note: If I use intent.putExtra(ContactsContract.Intents.Insert.POSTAL, address);
Galaxy S3 shows the address where as while using intent.putParcelableArrayListExtra(Insert.DATA, data);
this S3 not able to show the address.
Try saving both the structured fields as you do (for phones that support them) as well as the StructuredPostal.FORMATTED_ADDRESS
. You'll need to do the formatting yourself, though. That's what VCardEntry does, it seems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With