Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Add ringtone on Android 2.1

Add ringtone on Android 2.1

All your problems with Audio, Video and Images.

Add ringtone on Android 2.1

Postby Loken1989 » Tue Apr 12, 2011 12:07 pm

Hi

I wrote a peace of code to add a ringtone from a url in 2.1, In froyo it does not want to work at all
Code: Select all
sendBroadcast(new Intent(
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri
.fromFile(file)));

ContentValues values = new ContentValues();

values.put(MediaStore.MediaColumns.DATA,
file.getAbsolutePath());

values.put(MediaStore.MediaColumns.TITLE, filenameBase);
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");         
values.put(AudioColumns.IS_RINGTONE, true);
values.put(AudioColumns.IS_NOTIFICATION, false);
values.put(AudioColumns.IS_ALARM, false);
values.put(AudioColumns.IS_MUSIC, false);

Uri uri = MediaStore.Audio.Media.getContentUriForPath(file
.getAbsolutePath());

Uri newUri = RingtoneModule.this.getContentResolver()
.insert(uri, values);

RingtoneManager.setActualDefaultRingtoneUri(
RingtoneModule.this, RingtoneManager.TYPE_RINGTONE,
newUri);


when i get to insert i get this exception
Code: Select all
11-17 09:54:51.802: ERROR/DatabaseUtils(379): java.lang.IllegalStateException: Unknown URL: content://media/external/audio/albumart/-1
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.query(MediaProvider.java:1666)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.getAlbumArtOutputUri(MediaProvider.java:2983)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.makeThumbInternal(MediaProvider.java:3192)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.getThumb(MediaProvider.java:3070)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:2029)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at com.android.providers.media.MediaProvider.insert(MediaProvider.java:1843)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at android.content.ContentProvider$Transport.insert(ContentProvider.java:180)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:175)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at android.os.Binder.execTransact(Binder.java:288)
11-17 09:54:51.802: ERROR/DatabaseUtils(379):     at dalvik.system.NativeStart.run(Native Method)


thanks
Loken1989
Freshman
Freshman
 
Posts: 9
Joined: Wed Sep 08, 2010 8:04 pm

Top

Re: Add ringtone on Android 2.1

Postby luanbt » Thu Apr 14, 2011 7:53 am

You should delete data which existed in DB.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Uri uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath());
  2.  
  3.     getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" +
  4.              file.getAbsolutePath() + "\"", null);
  5.  
  6.     Uri newUri = getContentResolver().insert(uri, values);
  7.  
  8.     RingtoneManager.setActualDefaultRingtoneUri( activity.this,  
  9.              RingtoneManager.TYPE_RINGTONE,  newUri );
Parsed in 0.012 seconds, using GeSHi 1.0.8.4


or you also use another way like query DB to get Uri string which had setted the ringtone.
luanbt
Freshman
Freshman
 
Posts: 7
Joined: Tue Feb 22, 2011 8:00 am

Re: Add ringtone on Android 2.1

Postby mrcloister » Fri Aug 05, 2011 7:40 am

I had something similar and I finally worked out what a fix was for this. I posted it in stack overflow

http://stackoverflow.com/questions/4202 ... 67#6918067

thanks

MrC
mrcloister
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Aug 05, 2011 7:36 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 8 guests