0

I'm testing my app on different APIs and screen resolutions and ran into a problem using Android 2.1. Whenever I run the app, the main menu works along with all the other activities I made for it, except for one: the main game activity. I believe it's because the first error shown below. I'm guessing Android 2.1 doesn't support the SoundPool's OnLoadCompleteListener. I'm struggling to figure out an alternative to this so it works on both 2.2 and higher and 2.1 and lower Android versions. I'm pretty sure the OnLoadCompleteListener method is required when using SoundPool in 2.2 and above. I remember it not working without it. Anyone have suggestions?

Thanks

07-10 15:48:28.685: INFO/dalvikvm(363): Failed resolving Lorg/chinesetones/teacher/Game; interface 8 'Landroid/media/SoundPool$OnLoadCompleteListener;'

07-10 15:48:28.685: WARN/dalvikvm(363): Link of class 'Lorg/chinesetones/teacher/Game;' failed
07-10 15:48:28.685: ERROR/dalvikvm(363): Could not find class 'org.chinesetones.teacher.Game', referenced from method org.chinesetones.teacher.ChineseToneTeacherActivity.onClick
07-10 15:48:28.685: WARN/dalvikvm(363): VFY: unable to resolve const-class 38 (Lorg/chinesetones/teacher/Game;) in Lorg/chinesetones/teacher/ChineseToneTeacherActivity;

07-10 15:49:42.004: ERROR/AndroidRuntime(363): Uncaught handler: thread main exiting due to uncaught exception

07-10 15:49:42.074: ERROR/AndroidRuntime(363): java.lang.NoClassDefFoundError: org.chinesetones.teacher.Game

07-10 15:49:42.074: ERROR/AndroidRuntime(363):     at 
org.chinesetones.teacher.ChineseToneTeacherActivity.onClick(ChineseToneTeacherActivity.java:41)

07-10 15:49:42.074: ERROR/AndroidRuntime(363):     at android.view.View.performClick(View.java:2364)
datWooWoo
  • 843
  • 1
  • 12
  • 42
  • One helpful hint; if you look up the method or interface in the android doc's it will have the API level required. Check out http://developer.android.com/reference/android/media/SoundPool.OnLoadCompleteListener.html it shows level 8, so yeah 2.2 is required – Idistic Jul 10 '11 at 16:08
  • Is it pretty much impossible to use SoundPools and have it still work with both APIs then? Should I just go back to trying to make AudioTrack to work? I'm not sure what to do...AudioTrack and SoundPool are the only two choices I have because I need to be able to manage the audio's playback rate. AudioTrack is really confusing for me (writing to it) and always messes up. Any suggestions? – datWooWoo Jul 10 '11 at 16:09

1 Answers1

1

This other answers say that it's not possible

OnLoadCompleteListener Pre-2.2 No Solution

OnLoadCompleteListener Pre-2.2 No Solution

External searches seem to say the same thing

Of course it does not mean it's not possible, they said Mapview tilting could not be done and I figured out how to do it.

Unfortunately I am thinking the best solution might be load the sound why a splash screen is displayed, of course you would have to "guess" how long the sound takes to load.

Suggestion: You also might get a better idea of your problem by searching first [Android] OnLoadCompleteListener. I would also state problem more specifically in your title, for instance "What to use instead of OnLoadCompleteListener in 2.1 and below" or something like that.

The other thing you can do is get the android source code and see how they implemented the completion listener, you might be able to create something to emulate that.

Community
  • 1
  • 1
Idistic
  • 6,281
  • 2
  • 28
  • 38
  • I'm really new to Android programming, I'd like to try what you suggested, the splash screen way. How would I go about doing that? Thanks for the help! – datWooWoo Jul 10 '11 at 16:54
  • Alright well I did a Thread.sleep(1000); before playing the sound file and it seems to give it time to load (1 whole second should be enough). But now my sound files are extremely static-y and sound horrible...I can't figure out how to fix this... – datWooWoo Jul 10 '11 at 18:05
  • @lespommes I can't help much about the noise issue, probably post another question about that, also about the splash screen and then I can give you some skeleton code for that in context. – Idistic Jul 10 '11 at 18:12