0

I have an Android app for example a file manager.

When the user clicks a file I want to call open with dialog and run the app to open the file.

How can I do that?

Zoe
  • 27,060
  • 21
  • 118
  • 148
demosthenes
  • 1,151
  • 1
  • 13
  • 17
  • 1
    take look at here https://stackoverflow.com/questions/23148966/automatically-open-intent-chooser-for-the-file-android – Rohit Chauhan Aug 19 '18 at 13:49
  • i have this code: Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); File file = new File(dirPath); MimeTypeMap mime = MimeTypeMap.getSingleton(); String ext = file.getName().substring(file.getName().indexOf(".") + 1); String type = mime.getMimeTypeFromExtension(ext); intent.setDataAndType(Uri.fromFile(file), type); view.getContext().startActivity(intent); but it crashes. – demosthenes Aug 19 '18 at 14:45
  • i am in a ClickListener how i get the context? – demosthenes Aug 19 '18 at 15:21
  • i found this solution https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed – demosthenes Aug 19 '18 at 15:53

0 Answers0