我试图允许用户提供类名,然后启动Activity
,但我不断收到错误消息:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.intel.ave.androidclient/com.android.vending}; have you declared this Activity in your AndroidManifest.xml?
我没有将其放入 list 中,因为我不知道用户在运行时想要什么。
//package_name = input from the user
//MyContext = the activity context
Intent newprocess = new Intent(Intent.ACTION_MAIN);
newprocess.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
newprocess.setClassName(MyContext, package_name);
MyContext.startActivity(newprocess );
最佳答案
有 Intent 地启动外部 Activity 与在应用程序内启动有点不同。请参阅calling activity from external Activity 。引用那里,你会用这个来代替
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.the.other.app");
startActivity(intent);
关于android - 启动系统上的任何 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8454448/