ComponentName知识

以下是ComponentName的API

   /**
     * Create a new component identifier from a Context and Class object.
     * 
     * @param pkg A Context for the package implementing the component, from
     * which the actual package name will be retrieved.
     * @param cls The Class object of the desired component, from which the
     * actual class name will be retrieved.
     */
    public ComponentName(Context pkg, Class<?> cls) {
        mPackage = pkg.getPackageName();
        mClass = cls.getName();
    }

ComponentName(组件名称)可以用来打开其他应用程序中的Activity或服务。

Intent it=new Intent();  
it.setComponent(new ComponentName(String packageName,String activityName ));  
startActivity(it);  




你可能感兴趣的:(ComponentName知识)