zoukankan      html  css  js  c++  java
  • Service Intent must be explicit

    参考:
    http://blog.csdn.net/qs_csu/article/details/45114251

    我做阿里云账号登录的时候,遇到一个问题,不知道阿里云服务的包名。怎么办?第二种方法可以查,查询之后,自己手动设置setPackage 就可以了。

    public static Intent getExplicitIntent(Context context, Intent implicitIntent) {  
            // Retrieve all services that can match the given intent  
            PackageManager pm = context.getPackageManager();  
            List<ResolveInfo> resolveInfo = pm.queryIntentServices(implicitIntent, 0);  
            // Make sure only one match was found  
            if (resolveInfo == null || resolveInfo.size() != 1) {  
                return null;  
            }  
            // Get component info and create ComponentName  
            ResolveInfo serviceInfo = resolveInfo.get(0);  
            String packageName = serviceInfo.serviceInfo.packageName;  
            String className = serviceInfo.serviceInfo.name;  
            ComponentName component = new ComponentName(packageName, className);  
            // Create a new intent. Use the old one for extras and such reuse  
            Intent explicitIntent = new Intent(implicitIntent);  
            // Set the component to be explicit  
            explicitIntent.setComponent(component);  
            return explicitIntent;  
        }  

    可以查询手机上面的每一个action对应的Intent。哈哈,好强。

  • 相关阅读:
    01分数规划基本类型
    hdu3976
    hdu1430 康托展开+bfs预处理
    模板
    模板
    redis初始
    mybatis12
    mybatis13
    mybatis10
    springmvc10
  • 原文地址:https://www.cnblogs.com/caoxinyu/p/10568588.html
Copyright © 2011-2022 走看看