Click sound on android lazarus / 43-Android ---------------------------------------------------------------------- polypress · 2015-11-16 13:47 I need a click sound when buttons are pressed. I currently use vibrate, but this is heavy on the battery, and have looked at minesadorada's playsound package but it creates no sound, although no errors. I see it is for Windows and Linux. Can it be adapted to be used with android on smart phones? Alternatively, can the activity.java file be adapted to use the SoundPool facility, with access from lazarus? Again, I have tried this route but cannot get it to work. Regards ---------------------------------------------------------------------- felipemdc · 2015-11-17 14:39 Which kind of architecture are you using to make your app? There are various Lazarus Android support ways. I guess changing activity.java would be the easiest path. Create a JNI function on it and call it from Pascal on button click is 1 idea. ---------------------------------------------------------------------- polypress · 2015-11-18 08:06 Hi Felipemdc. Thank you for your reply. The architecture is laz4android (lazarus 1.1 FPC 2,7.1) on windows 7 to produce apk for android phone (android 4.1.2). I'll have to see about writing JNI functions. I don't think I've done that before. I'll search for examples. Regards ---------------------------------------------------------------------- ykot · 2015-11-18 17:04 I don't know if it might be an overkill, but on Android, you can also use BASS. You need to load it dynamically though, to make sure it is loaded after main shared library. ---------------------------------------------------------------------- polypress · 2015-11-23 17:07 .Quote from: felipemdc on November 17, 2015, 03:39:08 pmWhich kind of architecture are you using to make your app? There are various Lazarus Android support ways. I guess changing activity.java would be the easiest path. Create a JNI function on it and call it from Pascal on button click is 1 idea. The examples I've seen of processing new functions between java and lazarus seem to define new functions for java by coding in lazarus. What I am trying to do is to define new functions for lazarus by coding in java, because the required lazarus functions (eg playsound) don't seem to work using laz4android. Can you point me in the right direction? Regards ---------------------------------------------------------------------- felipemdc · 2015-11-24 21:03 I've never used laz4android, but here is a JNI example: https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/android- ndk/examples/jnitest/src/com/pascal/jnitest/ https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/android- ndk/examples/jnitest/jni/ ---------------------------------------------------------------------- polypress · 2015-11-28 12:26 Thank you Felipe Quote from: felipemdc on November 24, 2015, 10:03:41 pmI've never used laz4android, but here is a JNI example: https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/android- ndk/examples/jnitest/src/com/pascal/jnitest/ https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/android- ndk/examples/jnitest/jni/ As far as I can tell these links refer to producing code for java from lazarus code. I am trying to go the other way - produce code for lazarus from java code. This is because I can find no lazarus code to produce sound for android, whereas I have some simple java code which produces code for sound, but I cannot access it from lazarus. Another example is Hide/ShowVirtualKeyboard which is defined in activity.java and should be accessible by lazarus via customdrawnlclintf_android.inc but this fails. Has anyone found a way to access procedures from activity.java for use in lazarus? ---------------------------------------------------------------------- polypress · 2015-11-29 13:06 Success. You just borrow code from customdrawnint.pas, customdrawnobject_android.inc and customdrawnlclintf_android.inc without modifying them.