• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Set as ringtone with long click?

cwgdroid

Lurker
I am writing my first app, starting simple with a soundboard, and I have a feeling I won't run into too many problems seeing as how I'm familiar with java, but I have one thing that I have yet to figure out. How can I create an option on my soundboard buttons that when held down for a few seconds the user can set the sound as a ringtone? I have seen this on many soundboards on the market but have yet to figure it out. Thanks in advance.
 
Hi,

Start with the method "setOnLongClickListener()" that belongs the the View class (which Button is a child of). For example:

Button myButton = (Button)this.findViewById(R.id.MyButtonId);
myButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// something to do when clicked (like play sound)

}
});
myButton.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View view) {
// Do something else like set the mp3 as a ringtone
return true; // Indicating you handled it
}
});
 
Back
Top Bottom