First of all say that I don’t have much experience programming and that these are my first steps in Android.
I’ve developed an app for android, with minSdkVersion 8 and targetSdkVersion 16.
The application is like a photographic gallery that when you touch one of the pictures, shows a screen with a picture, a text, and play two sounds. You can view the previous or next screen sliding with your finger, or make it automatically sliding with some intervals.
I’ve tested the app in the emulator with android 2.2, and in some devices with android 2.3.5 and android 4.0.x.
With android 2.2 and 2.3.5 the app works correctly, but with android 4.0.x I’ve detected that the “manual” way works correctly, but the “automatic image sliding” doesn’t work.
The problem is that you select one of the pictures and the first activity runs correctly, but after the first one, the sounds of the next activity are heard before the layout of this activity is on the screen. If you exit to the main menu and choose other picture, the problem is the same. You see correctly the first activity and after that, the sounds advance the image of the activity.
I haven’t found nothing similar to my problem searching here. Can anyone help me?
EDITED to show some code.
The onCompletion code:
public void onCompletion(MediaPlayer mp) {
if(mp.equals(mpNom)){
try {
Thread.sleep (mpNom.getDuration()+500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else if(mp.equals(mpSo)){
try {
Thread.sleep (mpSo.getDuration());
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
The application does’t show any error and neither crash, but the UI is shown when the sounds are already reproducing.
Any idea? Thanks in advance.
Finally I’ve solved the problem.
It seems that the problem was in the OnCompletion method or in the code inside this method.
I rewrite the code making the app do the same but in a different way (programmaticaly talking), avoiding the OnCompletion method and now the app works perfect in android 4.0.x