我怎么能显示出pre在接触填充邮政地址屏幕与街道,城市,邮编android上 [英] How can i show a pre populated postal address in contacts screen with street , city , zip on android

查看:140
本文介绍了我怎么能显示出pre在接触填充邮政地址屏幕与街道,城市,邮编android上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下code在Android的填充联系人:

I am using following code for populating contacts in Android:

Intent addContactIntent = new Intent(Intent.ACTION_INSERT);
addContactIntent.setType(ContactsContract.Contacts.CONTENT_TYPE);
addContactIntent.putExtra(ContactsContract.Intents.Insert.NAME, "Store Name");
addContactIntent.putExtra(ContactsContract.Intents.Insert.PHONE, "1-869-270-9099");
addContactIntent.putExtra(ContactsContract.Intents.Insert.POSTAL, "postal address");*

但我也需要填充城市,街道和邮编邮政地址。如何使用上述code来填充这些领域?或任何替代方法这样做。

But I also need to populate city, street and zip in postal address. How to populate these fields using the above code? Or any alternate way to do so.

推荐答案

确定这里就是我所做的。

Ok here is what i have done.

                     ArrayList<ContentValues> data = new ArrayList<ContentValues>();
                    //Email
                      ContentValues row1 = new ContentValues();
                      row1.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
                      row1.put(Email.ADDRESS, "ADDRESSme");
                      data.add(row1);

                    //Website
                      ContentValues row2 = new ContentValues();
                      row2.put(Data.MIMETYPE, Website.CONTENT_ITEM_TYPE);
                      row2.put(Website.URL, "URLme");
                      data.add(row2);

                      //name
                      ContentValues row3 = new ContentValues();
                      row3.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
                      row3.put(StructuredName.DISPLAY_NAME, "NameMe");
                      data.add(row3);

                      //Address
                      ContentValues row4 = new ContentValues();
                      row4.put(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE);
                      row4.put(StructuredPostal.CITY, "CityMe");
                      row4.put(StructuredPostal.COUNTRY, "COUNTRYme");
                      row4.put(StructuredPostal.STREET, "STREETme");
                      row4.put(StructuredPostal.POSTCODE, "POSTCODEme");
                      data.add(row4);

                      //Phone 

                      ContentValues row5 = new ContentValues();
                      row5.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
                      row5.put(Phone.NUMBER, "NUMBERme");
                      data.add(row5);

                      Intent i = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
                      i.putParcelableArrayListExtra(Insert.DATA, data);

但有一点需要提醒大家的是, Insert.DATA 只能从API级别11.So此解决方案仅适用于Android 3.0 +

But one thing i need to remind you is that Insert.DATA is available only from API level 11.So this solution only works for Android 3.0+.

如果你们有什么更好的解决方案,请让我知道。

If you guys have any better solution please let me know.

这篇关于我怎么能显示出pre在接触填充邮政地址屏幕与街道,城市,邮编android上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆