Note that there are some explanatory texts on larger screens.

plurals
  1. POSet Ringtone class not doing anything
    primarykey
    data
    text
    <p>EDIT:</p> <p>The entire SetRingtone.java -- </p> <pre><code>public class SetRingtone extends Activity{ String TAG = "CFFS"; // Class var for logging - identifies the app in the logcat public boolean saveas(int ressound){ byte[] buffer=null; InputStream fIn = getBaseContext().getResources().openRawResource(ressound); int size=0; try { size = fIn.available(); buffer = new byte[size]; fIn.read(buffer); fIn.close(); } catch (IOException e) { // TODO Auto-generated catch block return false; } String path = Environment.getExternalStorageDirectory().getPath() + "/media/ringtone/ringtone.mp3"; String filename="College Football Fight Song"+".mp3"; boolean exists = (new File(path)).exists(); if (!exists){new File(path).mkdirs();} FileOutputStream save; try { save = new FileOutputStream(path+filename); save.write(buffer); save.flush(); save.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block return false; } catch (IOException e) { // TODO Auto-generated catch block return false; } sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+path+filename))); File k = new File(path, filename); ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, "College Football Fight Song"); values.put(MediaStore.MediaColumns.SIZE, 215454); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put(MediaStore.Audio.Media.ARTIST, ""); values.put(MediaStore.Audio.Media.DURATION, 230); values.put(MediaStore.Audio.Media.IS_RINGTONE, true); values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false); values.put(MediaStore.Audio.Media.IS_ALARM, false); values.put(MediaStore.Audio.Media.IS_MUSIC, false); //Insert it into the database Uri uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()); getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + k.getAbsolutePath() + "\"", null); Uri newUri = getContentResolver().insert(uri, values); RingtoneManager.setActualDefaultRingtoneUri( SetRingtone.this, RingtoneManager.TYPE_RINGTONE, newUri ); return false; } </code></pre> <p>Java where I want to set ringtone --</p> <pre><code>private OnLongClickListener onLongImageClick = new OnLongClickListener() { @Override public boolean onLongClick(View v) { if (v.getId() == R.id.boston_college_imageview) { SetRingtone(R.raw.acc_boston_college); } return false; } }; </code></pre> <p>and where I pass it off to SetRingtone.java --</p> <pre><code>private void SetRingtone(int soundID) { Intent otherIntent = new Intent(); otherIntent.setClassName("com.carboni.fightsongs", "com.carboni.fightsongs.SetRingtone"); otherIntent.putExtra("com.carboni.fightsongs.FILE_RES_ID", soundID); startActivity(otherIntent); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload