hch
2023-12-04 87c30b3995c5ccbad64eb965181af9ee4ec16420
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
41
42
43
44
45
46
47
48
49
50
51
package com.secondworld.sdk.command;
 
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
 
import com.secondworld.sdk.GameActivityProxy;
import com.secondworld.sdk.GameAppProxy;
import com.secondworld.sdk.utils.CodeU2A;
 
import org.json.JSONObject;
 
public class CmdGoToAppStore implements ICommand {
    @Override
    public int getCode() {
        return CodeU2A.GoToAppStore;
    }
 
    @Override
    public void process(JSONObject json) throws Exception {
        String url = "";
        if (json.has("url"))
            url = json.getString("url");
 
        String marketPkg="";
        if(json.has("marketPkg"))
            marketPkg=json.getString("marketPkg");
 
        Uri uri = Uri.parse("market://details?id=" + GameAppProxy.app.getPackageName());
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
 
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
                Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
                Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
 
        if (!TextUtils.isEmpty(marketPkg)) {
            intent.setPackage(marketPkg);
        }
 
        if (GameActivityProxy.I.activity == null)
            return;
 
        try {
            GameActivityProxy.I.activity.startActivity(intent);
        } catch (ActivityNotFoundException e) {
            if (!TextUtils.isEmpty(url))
                GameActivityProxy.I.activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        }
    }
}