|
Select a song from gallery: onActivityResult does not seem to work |
Iniciado por Zervarn, 06,oct. 2016 01:01 - 7 respuestas |
| |
| | | |
|
| |
Publicado el 06,octubre 2016 - 01:01 |
With Windev Mobile / Android I would like to select a song like you would select an image with the albumpicker. I created a class/activity in java to pick a song and that part works fine, but the onActivityResult of the activity never gets called. Am I missing something to get this working in Windev Mobile? Any other (working) ideas to select a song in Windev Mobile?
import android.app.Activity; import android.content.Intent; import java.lang.*; import android.util.*; import java.lang.Exception; import android.util.Log; import android.provider.MediaStore; import android.database.Cursor; import android.net.Uri;
PUBLIC static void PickMusic(string ProcedureRetour) { MusicGalleryActivity Im=new MusicGalleryActivity(); Im.GalleryProcedureRetour=ProcedureRetour; Im.SelectFileGallery(); }
PRIVATE static int RESULT_LOAD_IMAGE=1;
PUBLIC static class MusicGalleryActivity extends Activity{ PRIVATE static final int SELECT_MUSIC=10; PUBLIC string GalleryProcedureRetour=""; PUBLIC void SelectFileGallery() { Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI); getActiviteEnCours().startActivityForResult(i,SELECT_MUSIC); } @Override PROTECTED void onActivityResult(int requestCode,int resultCode,Intent Data) { IF (resultCode==RESULT_OK) { IF (requestCode==SELECT_MUSIC) { Uri selectedMusic=Data.getData();
string[] filePathColumn= {MediaStore.Audio.Media.DATA}; Cursor cursor=getContentResolver().query(selectedMusic, filePathColumn,null,null,null); cursor.moveToFirst(); int columnIndex=cursor.getColumnIndex(filePathColumn[0]); string musicPath=cursor.getString(columnIndex); cursor.close(); appelProcedureWL_String(GalleryProcedureRetour,musicPath); } } } } |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 3.661 mensajes Popularité : +175 (223 votes) |
|
Publicado el 06,octubre 2016 - 08:16 |
Opening a selected file (WINDEV Mobile)
WinDev MobileWindows Mobile
The following code is used to open a selected file. The file picker is opened in opening mode (fselOpen constant). Only the existing files are displayed in the file picker (fSelExist constant). The selected file is opened in read/write.
http://help.windev.com/en-US/…
FileNameAndPath is string FileID is int
FileNameAndPath = fSelect("MyFiles", "File.wav", "Selecting a file", ... "Text file (*.wav)" + TAB + "*.mp3" + CR + "All files (*.*)" + TAB + "*.*", ... "wav", fselOpen + fselExist)
http://help.windev.com/en-US/…
Sound("Tada.wav")
Sound("tada.wav", soundWait)
Sound("C:\MSOFFICE\Sounds\Car.wav", soundLoop)
Why not use the native commands, for that is developing the wheel?
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 9949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.com.br/ |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 3.661 mensajes Popularité : +175 (223 votes) |
|
Publicado el 06,octubre 2016 - 08:18 |
| |
| |
| | | |
|
| | |
| |
Publicado el 06,octubre 2016 - 09:26 |
Thank you for your answer... but...
According to the online help fselect is not supported in Windev Mobile / Android, so no reinventing of the wheel, unless the online help isn't up to date...
Questions remain:
-Does onActivityResult work with Windev Mobile? If so, what am I missing? If not, is there an alternative? -Is there another working solution to get a list (gallery) of all songs on your device and pick a song?
Thanks! |
| |
| |
| | | |
|
| | |
| |
Publicado el 06,octubre 2016 - 14:43 |
Hi
did you try a flistfile of the music directory on the sdcard?
You can then display the result in a looper (by example) and have your selector.
Best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM (open source)
More information on http://www.fabriceharari.com
Le 10/5/2016 à 5:01 PM, Zervarn a écrit :
With Windev Mobile / Android I would like to select a song like you would select an image with the albumpicker. I created a class/activity in java to pick a song and that part works fine, but the onActivityResult of the activity never gets called. Am I missing something to get this working in Windev Mobile? Any other (working) ideas to select a song in Windev Mobile? import android.app.Activity; import android.content.Intent; import java.lang.*; import android.util.*; import java.lang.Exception; import android.util.Log; import android.provider.MediaStore; import android.database.Cursor; import android.net.Uri;
public static void PickMusic(String ProcedureRetour) { MusicGalleryActivity Im=new MusicGalleryActivity(); Im.GalleryProcedureRetour=ProcedureRetour; Im.SelectFileGallery(); }
private static int RESULT_LOAD_IMAGE=1;
public static class MusicGalleryActivity extends Activity{ private static final int SELECT_MUSIC=10; public String GalleryProcedureRetour="";
public void SelectFileGallery() { Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI); getActiviteEnCours().startActivityForResult(i,SELECT_MUSIC); }
@Override protected void onActivityResult(int requestCode,int resultCode,Intent Data) { if (resultCode==RESULT_OK) { if (requestCode==SELECT_MUSIC) { Uri selectedMusic=Data.getData();
String[] filePathColumn= {MediaStore.Audio.Media.DATA};
Cursor cursor=getContentResolver().query(selectedMusic, filePathColumn,null,null,null); cursor.moveToFirst();
int columnIndex=cursor.getColumnIndex(filePathColumn[0]); String musicPath=cursor.getString(columnIndex); cursor.close();
appelProcedureWL_String(GalleryProcedureRetour,musicPath); } } } } |
| |
| |
| | | |
|
| | |
| |
Publicado el 06,octubre 2016 - 17:32 |
Hi, I already tried answering about 10 hours ago, but apparently until now my answer didn't get through...
So second attempt:
BOLLER a écrit :
> Why not use the native commands, for that is developing the wheel?
According to the online help fselect does not work with Windev Mobile and Android, so no reinventing of the wheel here, unless the help is not up to date...
Thus my questions remain:
- Does onActivityResult work with Windev Mobile, if so what could be wrong with my code or what else could I be needing to get it working? - Is there another option in Windev Mobile / android to get a gallery of all songs on the device where I can select a song?
Thanks in advance |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 3.661 mensajes Popularité : +175 (223 votes) |
|
Publicado el 06,octubre 2016 - 22:19 |
Hi,
It should work, if not ok you will open a call to technical support.
Sorry
Test the suggestion of Mr. Fabrice and see the example that has the Windev Mobile: ----------------------------------------------------------------------------------------------- Hi
did you try a flistfile of the music directory on the sdcard?
You can then display the result in a looper (by example) and have your selector.
Best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting -----------------------------------------------------------------------------------------------
See the example wd ftp client, I think that can be a good example for your needs:
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 9949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.com.br/Mensaje modificado, 06,octubre 2016 - 22:22 |
| |
| |
| | | |
|
| | |
| |
Publicado el 06,octubre 2016 - 23:57 |
Thank you both for your input.
Flistfile would work, but unfortunately it is limited to one directory and its sub-directories. My original approach would still have my preference because I wouldn't have to create a gallery myself and I would get all songs both from phone memory as from sdcard(s) and not just starting from one directory.
At the moment I'm using the following code (which works without activities and onActivityResult) instead of Flistfile to get all songs from the device and add them to a self made gallery...
PUBLIC static void GetMusicFiles() { ContentResolver CR = getActiviteEnCours().getContentResolver(); Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; string selection = MediaStore.Audio.Media.IS_MUSIC + "!= 0"; string sortOrder = MediaStore.Audio.Media.TITLE + " ASC"; Cursor cur = cr.query(uri, null, selection, null, sortOrder); int Count = 0; IF(cur != null) { Count = cur.getCount(); IF(Count > 0) { WHILE(cur.moveToNext()) { string musicPath = cur.getString(cur.getColumnIndex(MediaStore.Audio.Media.DATA)); appelProcedureWL_String(GalleryAddSong,musicPath); } } } cur.close(); }
The above code works fine, but If anybody can tell me how to get onActivityResult working in Windev Mobile it still would be of great help, because it opens doors to many other possibilities for getting things done within Windev Mobile/Android...
Anybody?
Thanks |
| |
| |
| | | |
|
| | | | |
| | |
|