fenster89411
Lurker
Hi Guys I have finished my app and added an about button.
On button press this happens:
popup window displays
kill popup
Audio file plays
I want
popup window displays
Audio file plays
kill popup
Is there a way to tell the pop up to play the audio rather than in the main code , what is happening makes sense but I want to change it. Just now the main code launches pop up , popup killed , main code continues and plays audio.
On button press this happens:
popup window displays
kill popup
Audio file plays
I want
popup window displays
Audio file plays
kill popup
Is there a way to tell the pop up to play the audio rather than in the main code , what is happening makes sense but I want to change it. Just now the main code launches pop up , popup killed , main code continues and plays audio.
Code:
switch (item.getItemId()) {
case R.id.action_settings:
//pop up
RelativeLayout = (android.widget.RelativeLayout) findViewById(R.id.relative);
layoutinflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
ViewGroup container = (ViewGroup) layoutinflater.inflate(R.layout.popup, null);
Aboutpopup = new PopupWindow(container, 900, 900, true); //1st number hor 2nd vert
Aboutpopup.showAtLocation(RelativeLayout, Gravity.CENTER, 0, 0); ////1st number hor 2nd vert (SMALLER VERT IS TOP)
//close popup if main window is clicked
container.setOnTouchListener(new View.OnTouchListener() {
[USER=1021285]@override[/USER]
public boolean onTouch(View view, MotionEvent motionEvent) {
final MediaPlayer mp = new MediaPlayer();//gonna play tunes
if (mp.isPlaying()) {
mp.stop();
}
try {
mp.reset();
AssetFileDescriptor afd;
afd = getAssets().openFd("355.mp3");
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
mp.prepare();
mp.start();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Aboutpopup.dismiss();
return true;
}
});
}
return super.onOptionsItemSelected(item);
Last edited: