Android SDK中有这样一个API:
public abstract Intent getLaunchIntentForPackage (String packageName)
如果packageName存在返回入口Intent, startActivity(Intent)可以启动应用,否则返回nullimport android.app.Activity;
下面有个小示例:
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PackageManager packageManager = getPackageManager();
Intent intent=new Intent();
intent =packageManager.getLaunchIntentForPackage("pkgName");
if(intent==null){
System.out.println("APP not found!");
}
startActivity(intent);
}
}