Parses out any app link data from the Intent of the Activity passed in.
@param activity Activity that was started because of an app link
@return AppLinkData if found. null if not.
972392
public static AppLinkData createFromActivity(Activity activity) {
        Validate.notNull(activity, "activity");
        Intent intent = activity.getIntent();
        if (intent == null) {
            return null;
        }

        AppLinkData appLinkData = createFromAlApplinkData(intent);
        if (appLinkData == null) {
            String appLinkArgsJsonString = intent.getStringExtra(BUNDLE_APPLINK_ARGS_KEY);
            appLinkData = createFromJson(appLinkArgsJsonString);
        }
        if (appLinkData == null) {
            // Try regular app linking
            appLinkData = createFromUri(intent.getData());
        }

        return appLinkData;
    }
1040063
@Override
  public String getMainActivity() throws AndroidSdkException {
    if (mainActivity == null) {
      try {
        mainActivity = extractApkDetails("launchable-activity: name='(.*?)'");
      } catch (ShellCommandException e) {
        throw new SelendroidException("The main activity of the apk " + apkFile.getName()
            + " cannot be extracted.");
      }
    }
    return mainActivity;
  }
1352947
public int getActivityIndex(ResolveInfo activity) {
        synchronized (mInstanceLock) {
            ensureConsistentState();
            List<ActivityResolveInfo> activities = mActivities;
            final int activityCount = activities.size();
            for (int i = 0; i < activityCount; i++) {
                ActivityResolveInfo currentActivity = activities.get(i);
                if (currentActivity.resolveInfo == activity) {
                    return i;
                }
            }
            return INVALID_INDEX;
        }
    }
715169
public static String getUrlParamsByMap(Map<String, String> data) throws UnsupportedEncodingException {
        if (data == null || data.isEmpty()) return null;

        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, String> i : data.entrySet()) {

            sb.append(i.getKey())
                    .append("=")
                    .append(URLEncoder.encode(i.getValue(), Charset.UTF_8))
                    .append("&");

        }
        String str = sb.toString();

        return str.substring(0, str.length() - 1);
    }
197888
@Override
    public void onActivityResume(Activity activity) {
        HMSAgentLog.d("autoShowFloatWindow:" + isShowFloatWindowCalled);
        if (isShowFloatWindowCalled) {
            showFinal(true, null, ApiClientMgr.INST.getApiClient());
        }
    }
977986
@Override
  public ICCASessionData getAppSessionData(Class<? extends AppSession> clazz, String sessionId) {
    if (clazz.equals(ClientCCASession.class)) {
      ClientCCASessionDataLocalImpl data = new ClientCCASessionDataLocalImpl();
      data.setSessionId(sessionId);
      return data;
    }
    else if (clazz.equals(ServerCCASession.class)) {
      ServerCCASessionDataLocalImpl data = new ServerCCASessionDataLocalImpl();
      data.setSessionId(sessionId);
      return data;
    }
    throw new IllegalArgumentException(clazz.toString());
  }
1249662
private void processHyperlinkData(ResourceAssignment assignment, byte[] data)
   {
      if (data != null)
      {
         int offset = 12;

         offset += 12;
         String hyperlink = MPPUtility.getUnicodeString(data, offset);
         offset += ((hyperlink.length() + 1) * 2);

         offset += 12;
         String address = MPPUtility.getUnicodeString(data, offset);
         offset += ((address.length() + 1) * 2);

         offset += 12;
         String subaddress = MPPUtility.getUnicodeString(data, offset);
         offset += ((subaddress.length() + 1) * 2);

         offset += 12;
         String screentip = MPPUtility.getUnicodeString(data, offset);

         assignment.setHyperlink(hyperlink);
         assignment.setHyperlinkAddress(address);
         assignment.setHyperlinkSubAddress(subaddress);
         assignment.setHyperlinkScreenTip(screentip);
      }
   }
471484
@Override
	public Links findLinksWithRel(LinkRelation relation, String representation) {

		Assert.notNull(relation, "LinkRelation must not be null!");

		try {
			Object parseResult = getExpression(relation).read(representation);
			return createLinksFrom(parseResult, relation);
		} catch (InvalidPathException e) {
			return Links.NONE;
		}
	}
759400
def main_activity(self):
        
        x = set()
        y = set()
        for item in self._dom.getElementsByTagName("activity"):
            for sitem in item.getElementsByTagName("action"):
                val = sitem.getAttribute("android:name")
                if val == "android.intent.action.MAIN":
                    x.add(item.getAttribute("android:name"))
            for sitem in item.getElementsByTagName("category"):
                val = sitem.getAttribute("android:name")
                if val == "android.intent.category.LAUNCHER":
                    y.add(item.getAttribute("android:name"))
        z = x.intersection(y)
        if len(z) > 0:
            return z.pop()
        return None
761080
@Nullable
  private static String getBuildDate() {
    try {
      URL res = JLanguageTool.class.getResource(JLanguageTool.class.getSimpleName() + ".class");
      if (res == null) {
        // this will happen on Android, see http://stackoverflow.com/questions/15371274/
        return null;
      }
      Object connObj = res.openConnection();
      if (connObj instanceof JarURLConnection) {
        JarURLConnection conn = (JarURLConnection) connObj;
        Manifest manifest = conn.getManifest();
        return manifest.getMainAttributes().getValue("Implementation-Date");
      } else {
        return null;
      }
    } catch (IOException e) {
      throw new RuntimeException("Could not get build date from JAR", e);
    }
  }
881990
@Override
    protected Object getRequestData() throws ActivityException {
        try {
            return executePreScript(getSqlQuery());
        }
        catch (Exception ex) {
            throw new ActivityException(ex.getMessage(), ex);
        }
    }
1013666
public static void dump(Intent intent) {
        if (intent == null) {
            QuickUtils.log.v("no intent found");
            return;
        }
        Bundle extras = intent.getExtras();
        QuickUtils.log.v("Intent[@" + Integer.toHexString(intent.hashCode()) + "] content:");
        QuickUtils.log.v("Action   : " + intent.getAction());
        QuickUtils.log.v("Category : " + intent.getCategories());
        QuickUtils.log.v("Data     : " + intent.getDataString());
        QuickUtils.log.v("Component: " + intent.getComponent().getPackageName() + "/" + intent.getComponent().getClassName());
        dumpFlags(intent.getFlags());
        QuickUtils.log.v("HasExtras: " + (extras != null && !extras.isEmpty()));
        dumpExtras(extras);
    }
311033
public JSONObject getLinkDataJsonObject() {
        JSONObject linkDataJson = new JSONObject();
        try {
            if (!TextUtils.isEmpty(channel)) {
                linkDataJson.put("~" + Defines.LinkParam.Channel.getKey(), channel);
            }
            if (!TextUtils.isEmpty(alias)) {
                linkDataJson.put("~" + Defines.LinkParam.Alias.getKey(), alias);
            }
            if (!TextUtils.isEmpty(feature)) {
                linkDataJson.put("~" + Defines.LinkParam.Feature.getKey(), feature);
            }
            if (!TextUtils.isEmpty(stage)) {
                linkDataJson.put("~" + Defines.LinkParam.Stage.getKey(), stage);
            }
            if (!TextUtils.isEmpty(campaign)) {
                linkDataJson.put("~" + Defines.LinkParam.Campaign.getKey(), campaign);
            }
            if (has(Defines.LinkParam.Tags.getKey())) {
                linkDataJson.put(Defines.LinkParam.Tags.getKey(), getJSONArray(Defines.LinkParam.Tags.getKey()));
            }
            linkDataJson.put("~" + Defines.LinkParam.Type.getKey(), type);
            linkDataJson.put("~" + Defines.LinkParam.Duration.getKey(), duration);
        } catch (JSONException ignore) {
        }
        return linkDataJson;
    }
1087565
@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        sessionTracker.getSession().onActivityResult(this.getActivity(), requestCode, resultCode, data);
    }
955972
private String getPostData(final ICommandLine cl) throws Exception {
        // String encoded = "";
        StringBuilder encoded = new StringBuilder();
        String data = cl.getOptionValue("post");
        if (data == null) {
            return null;
        }
        String[] values = data.split("&");
        for (String value : values) {
            String[] splitted = value.split("=");
            String key = splitted[0];
            String val = "";
            if (splitted.length > 1) {
                val = splitted[1];
            }
            if (encoded.length() != 0) {
                encoded.append('&');
            }
            encoded.append(key).append('=').append(URLEncoder.encode(val, "UTF-8"));
            // encoded += key + "=" + URLEncoder.encode(val, "UTF-8") + "&";
        }
        // if (encoded.endsWith("&")) {
        // StringUtils.removeEnd(encoded, "&");
        // }
        return encoded.toString();
    }
589575
public com.google.rpc.Help.LinkOrBuilder getLinksOrBuilder(
      int index) {
    return links_.get(index);
  }
539745
public static Link getLinkByRel(Entity entity, String... rel) {
        if(entity == null) {
            throw new IllegalArgumentException("entity cannot be null.");
        }
        if(ArrayUtils.isEmpty(rel)) {
            throw new IllegalArgumentException("rel cannot be null or empty");
        }
        List<Link> links = entity.getLinks();
        if (links == null)
            return null;
        Link link = null;
        for (Link l : links) {
            if (ArrayUtils.isNotEmpty(l.getRel()) && ArrayUtils.toString(rel).equals(ArrayUtils.toString(l.getRel()))) {
                link = l;
                break;
            }
        }
        return link;
    }