Hold down button to give option to save as ringtone?



I've looking for an answer for this question but no one really gives a clear answer on what code should be or look like. I've created am android app that plays sounds when you click a button but I'd like the use to have to option when they hold down on the button a display comes up where they can download or save as ringtone. Does anyone know how you would go about doing this?


Here's my code:



MediaPlayer mediaPlayer;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


Button Bus = (Button) findViewById(R.id.b1);
Bus.setOnClickListener (new OnClickListener(){

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Uri p1 = Uri.parse("android.resource://" + getPackageName() +
"/" + R.raw.bus);
mediaPlayer = MediaPlayer.create(MainActivity.this, p1);
mediaPlayer.start();
}

});


and my xml:



<Button
android:id="@+id/b1"
android:layout_width="125dp"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="18dp"
android:layout_marginStart="21dp"
android:layout_marginTop="25dp"
android:background="@drawable/jay"
android:shadowColor="#00FF00"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="10"
android:text="@string/b1"
android:textColor="#000000" />


Thanks, I'd really appreciate any help on this issue!


No comments:

Post a Comment