//方法一
Intent
intent = new
Intent();
//packageName为应用包名,activityFullName为具有luncher标识的activity的全路径名称
ComponentName
comp = new
ComponentName(packageName,activityFullName);
intent.setComponent(comp);
intent.setAction( "android.intent.action.VIEW" );
context.startActivity(intent);
//方法二
//上面这种方法启动应用需要同时具有包名和main
activity名。下面这种方法只需要包名即可:
Intent
queryIntent = new
Intent(
"android.intent.action.MAIN" );
List<ResolveInfo>
list = pm.queryIntentActivities(queryIntent, 0 );
ActivityInfo
info = null ;
for
(ResolveInfo l : list) {
if
((
"icelamp.LinkAngryBirds" ).equals(l.activityInfo.packageName))
{
info
= l.activityInfo;
break ;
}
}
if
(info !=
null )
{
ntent
intent = new
Intent();
intent.setComponent( new
ComponentName(info.packageName,info.name));
intent.setAction( "android.intent.action.VIEW" );
startActivity(intent);
}
|