Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set ringtone through an android application?
    primarykey
    data
    text
    <p>I am trying set a ringtone through my android application. I tried with this code</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String filepath ="/sdcard/sound.mp3"; File ringtoneFile = new File(filepath); ContentValues content = new ContentValues(); content.put(MediaStore.MediaColumns.DATA,ringtoneFile.getAbsolutePath()); System.out.println(ringtoneFile.getAbsolutePath()+"+++++++++++++++++++++++++"); content.put(MediaStore.MediaColumns.TITLE, "chinnu"); content.put(MediaStore.MediaColumns.SIZE, 215454); content.put(MediaStore.MediaColumns.MIME_TYPE, "sound.mp3"); content.put(MediaStore.Audio.Media.ARTIST, "Madonna"); content.put(MediaStore.Audio.Media.DURATION, 230); content.put(MediaStore.Audio.Media.IS_RINGTONE, true); content.put(MediaStore.Audio.Media.IS_NOTIFICATION, false); content.put(MediaStore.Audio.Media.IS_ALARM, false); content.put(MediaStore.Audio.Media.IS_MUSIC, false); //Insert it into the database String TAG=""; Log.i(TAG, "the absolute path of the file is :"+ ringtoneFile.getAbsolutePath()); Uri uri = MediaStore.Audio.Media.getContentUriForPath( ringtoneFile.getAbsolutePath()); Uri newUri = Context.getContentResolver().insert(uri, content); ringtoneUri = newUri; Log.i(TAG,"the ringtone uri is :"+ringtoneUri); RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE,newUri); } } </code></pre> <p>But I get the error: <code>context</code> cannot be resolved to a type. What does this mean? I am a beginner with android development. I set write_<code>external_storage permission</code> also.<br><br>What more do I have to do to run this application successfully?<br>Thanks in advance</p>
    singulars
    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.
    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