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)));
|
}
|
}
|
}
|