Yes, but it mostly depends on the functionality of your application or the specific design you would like to achieve/apply.
I foresee two options, but as I don't know more details about the application, I won't propose anything, just reference them:
A) If it's about a method in a class, you first have to create a new instance of the class and from the newly created instance, call that function.
That would be something like:
public void onClick(View v) {
BasicFunctions functions = new BasicFunctions();
functions.play();
}
And on the BasicFunctions.java
file, a play
method like:
public void play() {
//functionality to play the file
}
B) You can always define a static method in order to bypass creating extra instances:
public void onClick(View v) {
BasicFunctions.play();
}
And on the BasicFunctions.java
file, a play
method like:
public static void play() {
//functionality to play the file
}
But it's always up to you and want you want to achieve.
Edit
Seems like you just got the HelloWorld
example of the JFugue's site and tried to combine it with your Android application. However, I foresee many issues on it and one of them may be the root cause of your problem.
To begin with, I wasn't aware of this library, but for pure Java, it seems that the HelloWorld
example works as expected (instead of a small error, that I assume exists only on my local machine), which that I can hear a sound.
Now, according to the library's adjustment that you tried to accompilish to the Android OS, things are not so easy, so I would suggest going for enter link description here, an Android porting project of the library.
The project still doesn't provide any usage examples (so, if solving your issue, you could just fork it and provide one, if you want to, as it will be really helpful for future references, like yours), but its wiki pages seem to be well-explained:

Also, as a side note for the above project, please have a look at this answer.