@@ -111,10 +111,10 @@ public void actionViewIntent(String path, String mime, final Promise promise) {
111
111
Uri uriForFile = FileProvider .getUriForFile (getCurrentActivity (),
112
112
this .getReactApplicationContext ().getPackageName () + ".provider" , new File (path ));
113
113
114
+ Intent intent = new Intent (Intent .ACTION_VIEW );
114
115
if (Build .VERSION .SDK_INT >= 24 ) {
115
116
// Create the intent with data and type
116
- Intent intent = new Intent (Intent .ACTION_VIEW )
117
- .setDataAndType (uriForFile , mime );
117
+ intent .setDataAndType (uriForFile , mime );
118
118
119
119
// Set flag to give temporary permission to external app to use FileProvider
120
120
intent .setFlags (Intent .FLAG_GRANT_READ_URI_PERMISSION );
@@ -123,15 +123,16 @@ public void actionViewIntent(String path, String mime, final Promise promise) {
123
123
124
124
// Validate that the device can open the file
125
125
PackageManager pm = getCurrentActivity ().getPackageManager ();
126
- if (intent .resolveActivity (pm ) != null ) {
127
- this .getReactApplicationContext ().startActivity (intent );
128
- }
129
-
130
126
} else {
131
- Intent intent = new Intent (Intent .ACTION_VIEW )
132
- . setDataAndType ( Uri . parse ( "file://" + path ), mime ). setFlags ( Intent . FLAG_ACTIVITY_NEW_TASK );
127
+ intent . setDataAndType ( Uri . parse ( "file://" + path ), mime ). setFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
128
+ }
133
129
130
+ PackageManager pm = getCurrentActivity ().getPackageManager ();
131
+ if (intent .resolveActivity (pm ) != null ) {
134
132
this .getReactApplicationContext ().startActivity (intent );
133
+ promise .resolve (true );
134
+ } else {
135
+ promise .reject ("ENOAPP" , "No app installed for " + mime );
135
136
}
136
137
ActionViewVisible = true ;
137
138
0 commit comments