钛:如何在安卓系统的电话簿中添加联系人?[英] Titanium: How to add Contact in Phone book in Android?

本文是小编为大家收集整理的关于钛:如何在安卓系统的电话簿中添加联系人?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我想在电话簿中添加联系人.我可以正确地在iPhone中添加联系人,但在文档中我必须知道在Android中,电话簿是 readonly !!!

是否有任何其他方法可以添加?

谢谢..

推荐答案

解决了!我从这个链接.我们可以通过意图在Android中添加联系人.

if (Titanium.Platform.name == 'android') 
            {
                var intent = Ti.Android.createIntent
                ({
                    action: 'com.android.contacts.action.SHOW_OR_CREATE_CONTACT',
                    data: 'mailto:'+firstName+' '+lastName
                });
                    intent.putExtra('email', email);
                    intent.putExtra('email_type', 'Work');
                    intent.putExtra('phone', mobileno);
                    intent.putExtra('phone_type', 'mobile');
                    intent.putExtra('name', firstName+' '+lastName);

                Ti.Android.currentActivity.startActivity(intent);
            }

其他推荐答案

或者,您可以使用CreatePerson方法创建新的联系人. 您只需确保为每个属性都有正确的名称和结构. 请注意,电话号码是数组.

Ti.Contacts.createPerson({
    'firstName':fn.value, 
    'lastName':ln.value, 
    'phone':{'mobile':[mobile.value]}
});

本文地址:https://www.itbaoku.cn/post/1938208.html

问题描述

I want to add Contacts in phone book. I can add contacts in iPhone properly but in documentation I got to know that in Android, phone book is ReadOnly !!!

Is there any other way to add ?

Thanks..

推荐答案

Solved ! I got help from this Link . We can add contacts in Android by Intent.

if (Titanium.Platform.name == 'android') 
            {
                var intent = Ti.Android.createIntent
                ({
                    action: 'com.android.contacts.action.SHOW_OR_CREATE_CONTACT',
                    data: 'mailto:'+firstName+' '+lastName
                });
                    intent.putExtra('email', email);
                    intent.putExtra('email_type', 'Work');
                    intent.putExtra('phone', mobileno);
                    intent.putExtra('phone_type', 'mobile');
                    intent.putExtra('name', firstName+' '+lastName);

                Ti.Android.currentActivity.startActivity(intent);
            }

其他推荐答案

Alternatively, you can create a new contact by using the createPerson method. You just have to make sure that you have the proper names and structure for each of the properties. Note that the phone numbers are arrays.

Ti.Contacts.createPerson({
    'firstName':fn.value, 
    'lastName':ln.value, 
    'phone':{'mobile':[mobile.value]}
});