Setting contact custom ringtone, how?

I found out how it works. Below you can see the fixed code code: Uri contactData = ContactsContract.Contacts.CONTENT_URI; String contactId = contactData.getLastPathSegment(); Cursor localCursor = managedQuery(contactData, PROJECTION, null, null, null); localCursor.move(120/*CONTACT ID NUMBER*/); String str1 = localCursor.getString(localCursor.getColumnIndexOrThrow(“_id”)); String str2 = localCursor.getString(localCursor.getColumnIndexOrThrow(“display_name”)); Uri localUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, str1); ContentValues localContentValues = new ContentValues(); localContentValues.put(ContactsContract.Data.RAW_CONTACT_ID, contactId); localContentValues.put(ContactsContract.Data.CUSTOM_RINGTONE, f.getAbsolutePath()+”/Adventure.ogg”); … Read more

What is the default Account Type / Name for contacts on Android Contact Application?

I couldn’t find the way to get the SIM account yet. But I’m using the code below to get the default account name and type. public void getDefaultAccountNameAndType() { String accountType = “”; String accountName = “”; long rawContactId = 0; Uri rawContactUri = null; ContentProviderResult[] results = null; ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI).withValue(RawContacts.ACCOUNT_NAME, … Read more

Round button in Android

You may see implementation of this button in android source code It’s just ImageButton with circular png as background. Here is definition of their styles: <style name=”MinusButton”> <item name=”android:background”>@drawable/btn_circle</item> <item name=”android:src”>@drawable/ic_btn_round_minus</item> <item name=”android:contentDescription”>@string/description_minus_button</item> </style> <style name=”PlusButton”> <item name=”android:background”>@drawable/btn_circle</item> <item name=”android:src”>@drawable/ic_btn_round_plus</item> <item name=”android:contentDescription”>@string/description_plus_button</item> </style>

How load all the contacts with minimum time in Android

BETTER SOLUTION HERE….. private static final String[] PROJECTION = new String[] { ContactsContract.CommonDataKinds.Phone.CONTACT_ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER }; . . . ContentResolver cr = getContentResolver(); Cursor cursor = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION, null, null, null); if (cursor != null) { try { final int nameIndex = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); final int numberIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); String name, number; while (cursor.moveToNext()) { name … Read more

Prevent php web contact form spam

A simple trick is to create a honeypot field: html <!– within your existing form add this field –> <input type=”text” id=”website” name=”website”/> css /*in your css hide the field so real users cant fill it in*/ form #website{ display:none; } php //in your php ignore any submissions that inlcude this field if(!empty($_POST[‘website’])) die();

selecting contact from autocomplete textview

Add a onItemClickListener for the AutoCompleteTextView instead of having it as a seperate function. mTxtPhoneNo.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> av, View arg1, int index, long arg3) { Map<String, String> map = (Map<String, String>) av.getItemAtPosition(index); String name = map.get(“Name”); String number = map.get(“Phone”); mTxtPhoneNo.setText(“”+name+”<“+number+”>”); } }); or implement OnItemClickListener for your activity and set … Read more

Insert a new contact intent

You can choose whether you want to add the contact automatically, or open the add contact activity with pre-filled data: /** * Open the add-contact screen with pre-filled info * * @param context * Activity context * @param person * {@link Person} to add to contacts list */ public static void addAsContactConfirmed(final Context context, final … Read more

How to obtain all details of a contact in Android

Had to change a bit of the tutorial on Content Providers since it referenced deprecated classes, this might help. import android.provider.ContactsContract.Contacts; import android.database.Cursor; // Form an array specifying which columns to return, you can add more. String[] projection = new String[] { ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone ContactsContract.CommonDataKinds.Email }; Uri contacts = ContactsContract.Contacts.CONTENT_LOOKUP_URI; // id of the Contact … Read more