예제 #1
0
 /**
  * fetches the nuber of tsumegos available on gogameguru from the server
  *
  * @return the count or -1 on any error
  */
 public static final int getMaxTsumegos(Context ctx) {
   try {
     URL url =
         new URL(
             "http://"
                 + GobandroidConfiguration.backend_domain
                 + "/tsumegos/max?device_id="
                 + Secure.getString(ctx.getContentResolver(), Secure.ANDROID_ID));
     String count_str = NetHelper.downloadURL2String(url);
     count_str = count_str.replace("\n", "").replace("\r", "").trim(); // clean the string
     return Integer.parseInt(count_str);
   } catch (Exception e) {
     Log.w("cannot fetch the tsumego count" + e);
     return -1;
   }
 }
예제 #2
0
    @Override
    protected Void doInBackground(Void... params) {
      try {

        String device_id = Secure.getString(app.getContentResolver(), Secure.ANDROID_ID);
        String push_id = C2DMessaging.getRegistrationId(app);
        if (push_id.equals("")) push_id = "unknown";

        String url_str = "https://" + GobandroidConfiguration.backend_domain + "/push/register?";
        url_str += getURLParamSnippet("device_id", device_id);
        url_str += "&" + getURLParamSnippet("push_key", push_id);
        url_str += "&" + getURLParamSnippet("app_version", app.getAppVersion());

        String wanted_pushs = "";
        if (app.getSettings().isTsumegoPushEnabled()) wanted_pushs += "tsumego";
        if (wanted_pushs.equals("")) wanted_pushs = "none";

        url_str += "&" + getURLParamSnippet("wanted_pushs", wanted_pushs);
        url_str +=
            "&"
                + getURLParamSnippet(
                    "device_str",
                    Build.VERSION.RELEASE
                        + " | "
                        + Build.MANUFACTURER
                        + " | "
                        + Build.DEVICE
                        + " | "
                        + Build.MODEL
                        + " | "
                        + Build.DISPLAY
                        + " | "
                        + Build.CPU_ABI
                        + " | "
                        + Build.TYPE
                        + " | "
                        + Build.TAGS);

        URL url = new URL(url_str);
        NetHelper.downloadURL2String(url).replace("\n", "").replace("\r", ""); // .equals("saved");
      } catch (Exception e) {
        Log.w("cannot register push" + e);
      }
      return null;
    }