I'm trying to let a user export an excel file in my app and have the app automatically open the created excel file. The excel file is created and stored successfully using jxl, but when I try to open it with the Hancom Office Editor nothing happens other than my screen getting a dark overlay. Here's a gif:
I can't figure out what would cause this and can't find anything about it online.
I'm using the accepted answer from here to support my target SDK 28.
my export method:
public void onExport(View view){
try {
//write changes to excel file(changes made outide of function)
workbook.write();
workbook.close();
Toast.makeText(getApplication(),
"Data Exported to Excel Sheet", Toast.LENGTH_SHORT).show();
findViewById(R.id.btn_export).setEnabled(false);
//set file to saved excel file
File file = new File(Environment.getExternalStorageDirectory(),
race.getName()+".xls");
Uri path = FileProvider.getUriForFile(getApplicationContext(), "com.something.racecalculator.fileprovider", file);
Intent intent = new Intent(Intent.ACTION_VIEW);
Log.i("path: ", path.toString());
intent.setDataAndType(path, "image/jpg");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
} catch (IOException e) {
e.printStackTrace();
} catch (WriteException e) {
e.printStackTrace();
}
catch (ActivityNotFoundException e) {
Log.i("oh no:", "No application available to view excel");
}
}
My provider tag in AndroidManifest.xml(set as a child of ):
<provider
android:name=".GenericFileProvider"
android:authorities="com.something.racecalculator.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
I'm not getting any Errors or warnings as far as I can tell. Thanks for any help.