0

I made a code to export excel from intent android, but this code didn't work and show this alert .

 Intent intent = new Intent(Intent.ACTION_VIEW);
        if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
        Uri fileUri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", dir);
        intent.setDataAndType(fileUri,"application/*");
        } else {
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.setDataAndType(Uri.fromFile(dir),"application/*");
        }
        try {
        context.startActivity(intent);
        } catch (Exception ex) {
        ex.printStackTrace();
        Toast.makeText(context, "You need to have Microsoft Office Excel Installed here", Toast.LENGTH_LONG).show();
        } finally {
        Toast.makeText(context, "Success create report on " + dir.getPath() , Toast.LENGTH_LONG).show();
        }
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Lely Suju
  • 71
  • 2
  • 12

0 Answers0