Search Results

Search found 2 results on 1 pages for 'sgarman'.

Page 1/1 | 1 

  • Setting Ringtone notification from SD card file

    - by sgarman
    My goal is to set the users notification sound from a file that is stored onto the SD card from with in the application. I am using this code: if(path != null){ File k = new File(path, "moment.mp3"); ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, "My Song title"); values.put(MediaStore.MediaColumns.SIZE, 215454); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put(MediaStore.Audio.Media.ARTIST, "Some Artist"); values.put(MediaStore.Audio.Media.DURATION, 230); values.put(MediaStore.Audio.Media.IS_RINGTONE, false); values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true); values.put(MediaStore.Audio.Media.IS_ALARM, false); values.put(MediaStore.Audio.Media.IS_MUSIC, false); values.put(MediaStore.MediaColumns.DISPLAY_NAME, "Some Name"); //Insert it into the database Uri uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()); Uri newUri = MainActivity.this.getContentResolver().insert(uri, values); RingtoneManager.setActualDefaultRingtoneUri( MainActivity.this, RingtoneManager.TYPE_NOTIFICATION, newUri ); //RingtoneManager.setActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION, newUri); Toast.makeText(this, "Notification Ringtone Set", Toast.LENGTH_SHORT).show(); } When I run this on the device I keep getting the error: 06-12 15:19:36.741: ERROR/Database(2847): Error inserting is_alarm=false is_ringtone=false artist_id=35 is_music=false album_id=-1 title=My Song title duration=230 is_notification=true title_key=%D%\%%P%H%F%8%%R%<%R%B%4% mime_type=audio/mp3 date_added=1276370376 _display_name=moment.mp3 _size=215454 _data=/mnt/sdcard/Android/data/_MY APP PATH_/files/moment.mp3 06-12 15:19:36.741: ERROR/Database(2847): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed I have seen others using this technique and I can't find any documentation on which values actually need to be passed in to successfully add the file into the Android system so that it can be set as a notification.

    Read the article

  • Call Contact list on non-standard Android phones

    - by sgarman
    I am creating a widget that you can assign a contact to onClick. I used the method that is described here. This works great on standard Android phones such as the Motorola Droid, HTC Nexus One and HTC G1. The problem is for users who are using devices such as the HTC Incredible or HTC Droid Eris (Both running Sense UI) and I imagine on other phones who's OS deviates from the vanilla flavor of Android. Using my current method I thought that the device's OS would hook into whatever that manufacture chose to use for their Contact system however users are being sent to a random list of numbers, not their Contact list. Does anyone have a suggestion on how to get those Contacts or is this just another example of the Android fragmentation issue? Any help or insight is greatly appreciated.

    Read the article

1