lwb
2021-03-02 c4d0022c42c437aaabd24985ae5ee2fd862d28f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.secondworld.sdk.command;
 
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;
 
import com.secondworld.sdk.GameAppProxy;
import com.secondworld.sdk.utils.CodeU2A;
import com.secondworld.sdk.utils.LogUtil;
 
import org.json.JSONObject;
 
import java.io.File;
 
public class CmdInstallAPK implements ICommand {
    @Override
    public int getCode() {
        return CodeU2A.InstallAPK;
    }
 
    @Override
    public void process(JSONObject json) {
        try {
            String path = json.getString("path");
            File file = new File(path);
            if (!file.exists()) {
                LogUtil.w("InstallApp", "文件不存在");
                Toast.makeText(GameAppProxy.app, "找不安装文件", Toast.LENGTH_SHORT).show();
                return;
            }
            Intent _intent = new Intent(Intent.ACTION_VIEW);
            _intent.setDataAndType(Uri.fromFile(file),
                    "application/vnd.android.package-archive");
            _intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            GameAppProxy.app.startActivity(_intent);
        } catch (Exception e) {
            LogUtil.e("CmdInstallAPK", e);
        }
    }
}