Couldn't open Choose Contact window

chiwahwah

New Member
I've been trying to develop on a code that sets a ringtone to a contact , but I have a problem which is when I want to set the ringtone, and not doing anything, except showing an error I get in the LogCat "Couldn't open Choose Contact window".although the app runs very OK, until I try to assign the ringtone\[code\]//main classprivate boolean chooseContactForRingtone(MenuItem item){ try { //Go to the choose contact activity Intent intent = new Intent(Intent.ACTION_EDIT, getUri()); intent.setClassName( "com.ringdroid.alidev", "com.ringdroid.alidev.ChooseContactActivity"); startActivityForResult(intent, REQUEST_CODE_CHOOSE_CONTACT); } catch (Exception e) { Log.e("Ringdroid", "Couldn't open Choose Contact window"); } return true;}\[/code\]here's ChooseContactActivity\[code\] // On click, assign ringtone to contact getListView().setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View view, int position, long id) { assignRingtoneToContact(); } }); } catch (SecurityException e) { // No permission to retrieve contacts? Log.e("Ringdroid", e.toString()); } mFilter = (TextView) findViewById(R.id.search_filter); if (mFilter != null) { mFilter.addTextChangedListener(this); }}private boolean isEclairOrLater() {return Build.VERSION.SDK_INT >= 5;}private Uri getContactContentUri() {if (isEclairOrLater()) { // ContactsContract.Contacts.CONTENT_URI return Uri.parse("content://com.android.contacts/contacts");} else { return Contacts.People.CONTENT_URI;}}private void assignRingtoneToContact() { Cursor c = mAdapter.getCursor(); int dataIndex = c.getColumnIndexOrThrow(People._ID); String contactId = c.getString(dataIndex); dataIndex = c.getColumnIndexOrThrow(People.DISPLAY_NAME); String displayName = c.getString(dataIndex); Uri uri = Uri.withAppendedPath(getContactContentUri(), contactId); ContentValues values = new ContentValues(); values.put(People.CUSTOM_RINGTONE, mRingtoneUri.toString()); getContentResolver().update(uri, values, null, null); String message = getResources().getText(R.string.success_contact_ringtone) + " " + displayName; Toast.makeText(this, message, Toast.LENGTH_SHORT) .show(); finish(); return;}private Cursor createCursor(String filter) { String selection; if (filter != null && filter.length() > 0) { selection = "(DISPLAY_NAME LIKE \"%" + filter + "%\")"; } else { selection = null; } Cursor cursor = managedQuery( getContactContentUri(), new String[] { People._ID, People.CUSTOM_RINGTONE, People.DISPLAY_NAME, People.LAST_TIME_CONTACTED, People.STARRED, People.TIMES_CONTACTED }, selection, null, "STARRED DESC, " + "TIMES_CONTACTED DESC, " + "LAST_TIME_CONTACTED DESC, " + "DISPLAY_NAME ASC"); Log.i("Ringdroid", cursor.getCount() + " contacts"); return cursor;}public void beforeTextChanged(CharSequence s, int start, int count, int after) {}public void onTextChanged(CharSequence s, int start, int before, int count) {}public void afterTextChanged(Editable s) { String filterStr = mFilter.getText().toString(); mAdapter.changeCursor(createCursor(filterStr));}\[/code\]}
 
Back
Top