can open file with APP like the MT

This commit is contained in:
ShirosakiMio 2023-07-11 20:07:14 +08:00
parent cf57a0d16e
commit d3401ec718
1 changed files with 10 additions and 1 deletions

View File

@ -11,9 +11,11 @@ import android.view.Surface;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
import com.tungsten.fclauncher.FCLPath; import com.tungsten.fclauncher.FCLPath;
import java.io.File;
import java.io.Serializable; import java.io.Serializable;
public class FCLBridge implements Serializable { public class FCLBridge implements Serializable {
@ -191,7 +193,14 @@ public class FCLBridge implements Serializable {
} else if (targetLink.startsWith("file:")) { } else if (targetLink.startsWith("file:")) {
targetLink = targetLink.replace("file:", ""); targetLink = targetLink.replace("file:", "");
} }
intent.setDataAndType(Uri.parse(targetLink), "*/*"); Uri uri;
if (targetLink.startsWith("http")) {
uri = Uri.parse(targetLink);
} else {
//can`t get authority by R.string.file_browser_provider
uri = FileProvider.getUriForFile(context, "com.tungsten.fcl.provider", new File(targetLink));
}
intent.setDataAndType(uri, "*/*");
context.startActivity(intent); context.startActivity(intent);
} catch (Exception e) { } catch (Exception e) {
Log.e("openLink error", e.toString()); Log.e("openLink error", e.toString());