开发者

why this code run if? android

When tempPackageName_pInfo = "aaaa.asaddsdaa" "aaaa.asaddsdaa" is package name that non exist on android market. why code is run in "if". It should be run "else"

for (PackageInfo开发者_运维百科 pInfo : appinstalled) {
        String tempPackageName_pInfo = pInfo.packageName.toString();
        appinstalledTest = pm
                .getInstalledApplications(PackageManager.GET_PERMISSIONS);
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("market://details?id="
                + tempPackageName_pInfo));
        List<ResolveInfo> list = pm.queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);// 0
    if (list.size() > 0) { runIf(); } else { runElse(); }

Sorry for my bad English.


As stated in the docs for queryIntentActivities

Retrieve all activities that can be performed for the given intent.

As far as I understand this means that there is at least the Market activity, which can be preformed for this intent. This method can not rely on either this particular package exists in the Market or not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜