|
@@ -1,47 +0,0 @@
|
|
|
-package com.gfg.gfglibrary;
|
|
|
-
|
|
|
-import android.app.Activity;
|
|
|
-import android.content.Context;
|
|
|
-import android.content.Intent;
|
|
|
-import android.net.Uri;
|
|
|
-import android.os.Build;
|
|
|
-import android.os.Bundle;
|
|
|
-
|
|
|
-import androidx.core.content.FileProvider;
|
|
|
-
|
|
|
-import com.unity3d.player.UnityPlayerActivity;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-
|
|
|
-public class GfgActivity extends UnityPlayerActivity {
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- //setContentView(R.layout.activity_main);
|
|
|
- TestString();
|
|
|
- new SaveImage();
|
|
|
- }
|
|
|
-
|
|
|
- public String TestString()
|
|
|
- {
|
|
|
- return "Test String";
|
|
|
- }
|
|
|
-
|
|
|
- public void InstallApk(Context context, String apkPath){
|
|
|
-
|
|
|
- File file = new File(apkPath);
|
|
|
- Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
|
- if(Build.VERSION.SDK_INT>=24) { //Android 7.0及以上
|
|
|
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
|
- Uri apkUri = FileProvider.getUriForFile(context, context.getPackageName()+".fileprovider", file);
|
|
|
- //对目标应用临时授权该Uri所代表的文件
|
|
|
- intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
|
|
- }else{
|
|
|
- intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
|
|
|
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
- }
|
|
|
- context.startActivity(intent);
|
|
|
-
|
|
|
- }
|
|
|
-}
|