New file |
| | |
| | | package com.secondworld.sdk.command; |
| | | |
| | | import android.content.ActivityNotFoundException; |
| | | import android.content.Intent; |
| | | import android.net.Uri; |
| | | |
| | | 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"); |
| | | |
| | | 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 (GameActivityProxy.I.activity == null) |
| | | return; |
| | | |
| | | try { |
| | | GameActivityProxy.I.activity.startActivity(intent); |
| | | } catch (ActivityNotFoundException e) { |
| | | if (url != null && !url.isEmpty()) |
| | | GameActivityProxy.I.activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); |
| | | } |
| | | } |
| | | } |