componentname
componentname(组件名称)是用来打开其他应用程序中的Activity或服务的。
Identifier for a specific APPlication component (Activity
, Service
, BroadcastReceiver
,
or contentprovider
)
that is available. Two pieces of information, encapsulated here, are required to identify a component: the package (a String) it exists in, and the class (a String) name inside of that package.
用法:
ComponentName cn=new ComponentName("com.example.myapp", "com.example.myapp.MainActivity");
intent intent = new Intent();
intent.setComponent(cn);
startActivityForResult(intent,1);
相关阅读
一、ComponentName简介 ComponentName,顾名思义,就是组件名称,这个类主要用来定义一个应用程序的组件,通过调用Intent中的setCompone