[Android] AudioUtil: take a context as argument for setRingtone() instead of an activity

Adrien Maglo git at videolan.org
Fri Mar 21 18:02:05 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Mar 21 17:56:42 2014 +0100| [db2d342509906605d55a715cf24493d706d7d4c2] | committer: Adrien Maglo

AudioUtil: take a context as argument for setRingtone() instead of an activity

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=db2d342509906605d55a715cf24493d706d7d4c2
---

 .../src/org/videolan/vlc/gui/audio/AudioUtil.java    |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
index db5b998..caa7346 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
@@ -62,10 +62,10 @@ public class AudioUtil {
     public static String COVER_DIR = null;
     public static String PLAYLIST_DIR = null;
 
-    public static void setRingtone( Media song, Activity activity){
+    public static void setRingtone(Media song, Context context){
         File newringtone = LibVlcUtil.URItoFile(song.getLocation());
         if(!newringtone.exists()) {
-            Toast.makeText(activity.getApplicationContext(),activity.getString(R.string.ringtone_error), Toast.LENGTH_SHORT).show();
+            Toast.makeText(context.getApplicationContext(),context.getString(R.string.ringtone_error), Toast.LENGTH_SHORT).show();
             return;
         }
 
@@ -82,23 +82,23 @@ public class AudioUtil {
         Uri uri = MediaStore.Audio.Media.getContentUriForPath(newringtone.getAbsolutePath());
         Uri newUri;
         try {
-            activity.getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + newringtone.getAbsolutePath() + "\"", null);
-            newUri = activity.getContentResolver().insert(uri, values);
+            context.getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + newringtone.getAbsolutePath() + "\"", null);
+            newUri = context.getContentResolver().insert(uri, values);
             RingtoneManager.setActualDefaultRingtoneUri(
-                    activity.getApplicationContext(),
+                    context.getApplicationContext(),
                     RingtoneManager.TYPE_RINGTONE,
                     newUri
                     );
         } catch(Exception e) {
-            Toast.makeText(activity.getApplicationContext(),
-                    activity.getString(R.string.ringtone_error),
+            Toast.makeText(context.getApplicationContext(),
+                    context.getString(R.string.ringtone_error),
                     Toast.LENGTH_SHORT).show();
             return;
         }
 
         Toast.makeText(
-                activity.getApplicationContext(),
-                activity.getString(R.string.ringtone_set, song.getTitle()),
+                context.getApplicationContext(),
+                context.getString(R.string.ringtone_set, song.getTitle()),
                 Toast.LENGTH_SHORT)
                 .show();
 



More information about the Android mailing list