I wrote this simple Main.java and need to know how to use simple codes to set a soundpool or mediaplayer as a ringtone. Direct question is: set as ringtone by button "b2"
there are few sources in stackoverflow but I could n't understand any of them. thanks in advance
My codes:
public class Main extends Activity implements OnClickListener{
SoundPool sp;
int dicesound;
Button play, setAsRingtone;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
dicesound = sp.load(this, R.raw.onedice, 1);
play = (Button) findViewById(R.id.b1);
setAsRingtone = (Button) findViewById(R.id.b2);
play.setOnClickListener(this);
setAsRingtone.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.b1:
sp.play(dicesound, 1, 1, 0, 0, 1);
break;
case R.id.b2:
// HOW TO SET "dicesound" SOUND AS A RINGTONE ???
break;
}
}
}