Commit 4406eb1c authored by fallenstardust's avatar fallenstardust

更改为分享文件路径

adapt provider
parent 2a9fb92c
...@@ -7,12 +7,14 @@ import android.os.Bundle; ...@@ -7,12 +7,14 @@ import android.os.Bundle;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
import java.io.File; import java.io.File;
import cn.garymb.ygomobile.AppsSettings; import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.Constants; import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.core.IrrlichtBridge; import cn.garymb.ygomobile.core.IrrlichtBridge;
import cn.garymb.ygomobile.lite.BuildConfig;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
public class ShareFileActivity extends BaseActivity{ public class ShareFileActivity extends BaseActivity{
...@@ -34,14 +36,15 @@ public class ShareFileActivity extends BaseActivity{ ...@@ -34,14 +36,15 @@ public class ShareFileActivity extends BaseActivity{
String ext = intent.getStringExtra(IrrlichtBridge.EXTRA_SHARE_FILE); String ext = intent.getStringExtra(IrrlichtBridge.EXTRA_SHARE_FILE);
//TODO //TODO
Toast.makeText(this, title+"."+ext, Toast.LENGTH_LONG).show(); Toast.makeText(this, title+"."+ext, Toast.LENGTH_LONG).show();
File shareFile = null; String shareFile = null;
if (ext.equals("yrp")) { if (ext.equals("yrp")) {
shareFile = new File(AppsSettings.get().getResourcePath() + "/" + Constants.CORE_REPLAY_PATH + "/" + title); shareFile = AppsSettings.get().getResourcePath() + "/" + Constants.CORE_REPLAY_PATH + "/" + title;
} else if (ext.equals("lua")) { } else if (ext.equals("lua")) {
shareFile = new File(AppsSettings.get().getResourcePath()+ "/" + Constants.CORE_SINGLE_PATH + "/" + title); shareFile = AppsSettings.get().getResourcePath()+ "/" + Constants.CORE_SINGLE_PATH + "/" + title;
} }
Intent shareIntent = new Intent(Intent.ACTION_SEND); Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(shareFile)); shareIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".fileprovider", new File(shareFile)));
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.setType("*/*");//此处可发送多种文件 shareIntent.setType("*/*");//此处可发送多种文件
startActivity(Intent.createChooser(shareIntent, "分享到")); startActivity(Intent.createChooser(shareIntent, "分享到"));
} }
......
...@@ -4,4 +4,10 @@ ...@@ -4,4 +4,10 @@
<external-path name="beta_external_path" path="Download/"/> <external-path name="beta_external_path" path="Download/"/>
<!--/storage/emulated/0/Android/data/${applicationId}/files/apk/--> <!--/storage/emulated/0/Android/data/${applicationId}/files/apk/-->
<external-path name="beta_external_files_path" path="Android/data/"/> <external-path name="beta_external_files_path" path="Android/data/"/>
<external-path
path="Android/data/${applicationId}/"
name="files_root" />
<external-path
path="."
name="external_storage_root" />
</paths> </paths>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment