In my app i'm trying to create a Contact by calling the standard Create/Edit contact Activity.
I've found how to make it work but not exactly the way I like.
For now I manage to call the standard create contact activity with the following intent extra:
Intent i = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, Uri.parse(String.format("tel: %s", data.getPhone())));
i.addCategory(Intent.CATEGORY_DEFAULT);
i.putExtra(ContactsContract.Intents.EXTRA_FORCE_CREATE, true);
i.putExtra(ContactsContract.Intents.Insert.NAME, data.getName());
i.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK);
i.putExtra(ContactsContract.Intents.Insert.PHONE, org.getPhone());
i.putExtra(ContactsContract.Intents.Insert.POSTAL_TYPE, ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK);
i.putExtra(ContactsContract.Intents.Insert.POSTAL, org.getAddress() + " " + org.getZipCode());
i.putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE, ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK);
i.putExtra(ContactsContract.Intents.Insert.EMAIL, org.getEmail());
startActivity(i);
All the data is filled properly except the address field as you can see in the following picture: http://img689.imageshack.us/img689/1073/capturevvm.png
I'd like to specify each part of the address in the separate field. Is there a way to do it with an Intent?
I tried this, but it did not work.
i.putExtra(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE, ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK);
i.putExtra(ContactsContract.CommonDataKinds.StructuredPostal.STREET, "toto");
i.putExtra(ContactsContract.CommonDataKinds.StructuredPostal.CITY, "paris");
Any idea?
contactIntent.putExtra(ContactsContract.Intents.Insert.POSTAL, "2 rue de Romme, 75000 Paris");
contactIntent.putExtra(ContactsContract.Intents.Insert.POSTAL_TYPE, ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK);
You can add the contact using the technique at New contacts created using ContactsContract do not appear in Contacts app
Then show it using your technique.
Related
i´m reading the documentation of paypal https://developer.paypal.com/limited-release/paypal-mobile-checkout/android/ ,in the example show
but i have the next error, the parameters doesn´t match. Only works when i remove this parameter
BuildConfig.APPLICATION_ID + "://paypalpay", how i can pass the parameter even later?
config= PayPalConfiguration().environment(PayPalConfiguration.ENVIRONMENT_SANDBOX).clientId(client_id)
.environment(CONFIG_ENVIRONMENT)
.merchantName("Example Merchant")
.merchantPrivacyPolicyUri(Uri.parse("https://www.example.com/privacy"))
.merchantUserAgreementUri(Uri.parse("https://www.example.com/legal"))
var i= Intent(this, PayPalService::class.java)
i.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION,config)
startService(i)
I was trying to export contacts from my application to the native android contacts.
I found the following solution here on this site: Titanium: How to add Contact in Phone book in Android?.
And it kinda works. The intent gets started. Only problem is, that android does not recognize most of the Extras i put in. So almost every field is blank. It does not matter if I replace contactModel with a simple String, the result is the same.
So i was wondering if the keys are simply wrong, but there seems no proper documentation on appcelerator. Probably something has changed over the past years or I am just missing something. Does anybody know how to do it the right way.
Code Snippet:
if (OS_ANDROID) {
var intent = Ti.Android.createIntent({
action : 'com.android.contacts.action.SHOW_OR_CREATE_CONTACT',
data : 'mailto:' + contactModel.get('contact_first_name') + ' ' + contactModel.get('contact_last_name')
});
intent.putExtra('email', contactModel.get('contact_email'));
intent.putExtra('email_type', 'Work');
intent.putExtra('phone', contactModel.get('contact_mobile_number'));
intent.putExtra('phone_type', 'mobile');
intent.putExtra('name', contactModel.get('contact_first_name') + ' ' + contactModel.get('contact_last_name') );
intent.putExtra('address', addressModel.get('address_street') + ", " + addressModel.get('address_city'));
intent.putExtra('address_type', 'Work');
Ti.Android.currentActivity.startActivity(intent);
}
Thx in advance. :)
The first parameter of putExtra() also accepts one of the constants Ti.Android.... So instead of email you would probably have to use Ti.Android.EXTRA_EMAIL.
I think you can find quite a lot in the docs, e.g. here:
EXTRA constant properties in Ti docs
EXTRA constants in Android docs
Android Intents in Ti docs
I am getting different numbers from Contacts and passing them to SMS application. I am using the following:
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:"+numbers) ); //numbers separated with ;
intent.putExtra( "sms_body", body );
startActivity( intent );
The problem is if I separate numbers with ' ; ', it does not work on Galaxy S but works on others like HTC, Samsung Gio etc... On Galaxy S, it works if I separate numbers with comma ' , '. So how to resolve this issue?
Normally using a semicolon (';') is the right choice to separate phone numbers. So you should use this. It might be due to vendor specific adjustments or custom vendor applications that it does not work on Galaxy S for example.
I would propse to use semicolon everywhere except for Samsung devices. You unfortunately have to do this ugly vendor specific decision within your source code.
String separator = "; ";
if(android.os.Build.MANUFACTURER.contains("Samsung")){
separator = ", ";
}
// set the numbers string with the use of 'separator'
Note that the solution provided (using the os.Build.MANUFACTURER string) does not work in all situations!
I have several users that use a Samsung device which run's a Cyanogenmod version of Android. In this situation the MANUFACTURER string contains "Samsung", but the separator should be a ";" instead of the ",". I did not find a solution for this issue yet...
I am developing app which add contact info to android contact list .to How to add postal address to contacts in android programmatically ?
It's been a while that this has been asked but maybe someone else is still interested in it. How to add a contact with address info:
import static android.provider.ContactsContract.Data;
import static android.provider.ContactsContract.Intents.Insert;
private void createContactIntent() {
Intent contactIntent = new Intent(ContactsContract.Intents.Insert.ACTION, ContactsContract.Contacts.CONTENT_URI);
contactIntent.setType(ContactsContract.Contacts.CONTENT_TYPE);
contactIntent.putExtra(Insert.NAME, "Sergio Mendes");
contactIntent.putExtra(Insert.COMPANY, "Company One");
contactIntent.putExtra(Insert.POSTAL, "Street 1, 9999 City, Country");
contactIntent.putExtra(Data.IS_SUPER_PRIMARY, 1);
startActivity(contactIntent);
}
Note that some devices like Samsung S5 / A5 will put the whole address into the "street" field. If you have any optimizations for this let me know.
Postal address are stored like all the other info in the DATA table with a
MIMEtype == ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE
Please google ContactsContract.CommonDataKinds.StructuredPostalto find all the info.
If you need to know how to edit a contact in general I would suggest you to have a look to the SampleSyncAdapter in the Android SDK. It is a sync adapter so you don't need to study everything but updateContact in ContactManager is a good point to start with.
iam just practicing with phone gap for android app. I found a piece of code in docs.phonegap.com, regarding adding contacts
function onDeviceReady()
{
alert('onDeviceReady: PhoneGap1');
var myContact = navigator.contacts.create({"displayName": "Test User"});
alert('onDeviceReady: PhoneGap2');
myContact.gender = "male";
console.log("The contact, " + myContact.displayName + ", is of the " + myContact.gender + " gender");
}
When i run this i am getting only the alert box and the name is not added in my contacts. How to add the contacts....
Please tell me how to add data and open the device default contacts...
Simon Mac Donald has written a great blog post on contacts with PhoneGap and Android.
http://simonmacdonald.blogspot.com/2011/09/saving-contacts-with-phonegap-android.html
It should help you out as there are a few steps to it.
The quick answer for those of you searching, is that you have to call
myContact.save()
in order to persist the contact that you just created.