tauri-apps / tauri-apps/plugins-workspace

`opener` can only open URLs.

Open
#2,383 1 comment 4 reactions 0 assignees View on GitHub
platform: android platform: ios plugin: opener type: feature request
Dominant language
Rust
Stars
1.8k
Forks
602
Avg merge
4d 14h
Merged PRs (30d)
9

Description

When a local app-owned file path is passed to the `opener` plugin, it will tell us that there's no Activity that can open that uri. This is because FileProvider is not used, therefore a local uri is never converted to a ContentProvider uri, and therefore other apps cannot open our local files.

This code would work btw
```
import android.content.Intent
import androidx.core.content.FileProvider
import java.io.File
[...]

fun openPath(path: String) {
try {
val file = File(path);
val uri = FileProvider.getUriForFile(activity, activity.packageName + ".fileprovider", file);
val intent = Intent(Intent.ACTION_VIEW);
intent.setData(uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
activity.applicationContext?.startActivity(intent);
}catch (e: Exception){

}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.