Hello. Ok, my English is not so good, but I'll try my best.
You'll have to set the correct Data and Type. You have to define the Type by yourself, by getting the fileextension. Type means the main MIME-type like audio/* or image/*. For example: You clicked at the file "MyFavouriteSong.mp3" you have to parse for the file-extension, here ".mp3". In the list defined by yourself (maybe in a Textfile or as a resource- array), you look for that extension and use the main MIME-type as Type. (should now look like "audio"). If you have the Type, you can call the "setDataAndType" Method with parameters like shown in the sample source below. Android will show you a Dialog with all Application that can handle the given Type, which did not mean that the Application can Handle the File by itself. ;-) *** CODE *** // Create an Intent Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(android.content.Intent.ACTION_VIEW); // Category where the App should be searched String category = new String("android.intent.category.DEFAULT"); // Setting up the data and the type for the intent intent.setDataAndType(Uri.fromFile(aDirectory), type+"/ *"); // will start the activtiy found by android or show a dialog to select one startActivity(intent); *** CODE END *** This is the way i do, but i don't know it's the right one. Regards, OC On 26 Sep., 11:25, Timbobsteve <[EMAIL PROTECTED]> wrote: > Hi All, > > I posted this in the beginners section, but received no response. > Sorry if it is bad etiquette to re-post here, it just seems that there > is a lot more activity in this list. > > I am running through the FileBrowser tutorial over @ anddev.org and > have it working fairly well, but the one thing I cannot get working is > Opening files when they are clicked on. > > I always seem to get a "ActivityNotFoundException: no activity found > to handle { action: android.content.Intent.ACTION_VIEW data=file:/// > sdcard/myfile.txt} " > > My openFile() function looks like this: > > private void openFile() { > try { > Intent myIntent = new > Intent(android.content.Intent.ACTION_VIEW, Uri.fromFile(myFile)); > startActivity(myIntent); > } catch (ActivityNotFoundException e) { > e.printStackTrace(); > } > } > > Can anyone see any problems with this? Is it just that there are no > Apps registered to handle opening of .png images and .txt files? Or is > my code wrong? > > Regards, > Timbobsteve --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---