Closing Media player through activity starter?

Last Updated:

  1. ClassixUK

    ClassixUK Member

    Hey guys,

    I am building an app where the user can click a button, choose an audio file and then play that audio file on demand by clicking a button. A label would display the file path to the audio file.

    I found I needed to use the activity starter to launch an existing file browser, only problem is that when I click on my desired sound file, it will play it. After hitting the back button a few times, I get back to my app screen but the file path isn't displayed.

    I suppose this is 2 questions.

    Does anybody know How I can kill the media player and go back to my App ?
    I have tried Close Screen with Result, the best I got with it was, closing MY app's screen with I hit back, not exactly helpful lol.

    And does anybody know why I cannot display my file path. I have tried Set Text as Resultname/DataUri/ResultUri but neither of them seem to work.

    any help would be greatly appreciated.
    Thanks for your time.

  2. tAIIC

    tAIIC Active Member

    1) The close screen blocks are only meant to close your app, hence the result. :) Hardware button access is also not supported yet. Also, when you open another app, your app does not pass any controls so you are at the mercy of how that app exits. Usually you can get back to your app with the back key. I have noticed that if you exit your app using the home button, it remains running in the background. Need to install on device for this.

    2) Why not just set the label.text to the .text value of the component holding the file path variable?

    I know the answer to the first question isn't what you're looking for, but hopefully the second will help. :)

    App Inventor Info Center
  3. ClassixUK

    ClassixUK Member

    Thanks for your response, the media player issue isn't a problem if I could pass back the correct path but all the methods I have tried do not work, what would you expect to carry the location ?
    I have tried:


    but they all return nothing, when I run adb logcat it says result = 0

    what would you suggest ?

    Thanks again
  4. tAIIC

    tAIIC Active Member

    I just re-read your original post again. I think I misunderstood. You are opening the file browser and picking a file. You want to take that selection and write it to a label.text. Correct?

    Are you using activitystarter.afteractivity to set .text to the result?

    If that doesn't work for you, I recommend also posting on the official AI forums.
    App Inventor for Android

    App Inventor Info Center

Share This Page