我想通过intent从我的安卓应用程序中启动股票天气应用程序,但我一直收到一个强制关闭运行时错误,而LogCat什么也没有给我。我尝试用来实现这一点的代码是:
public void startWeatherActivity() {
Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(ComponentName.unflattenFromString("org.anddev.android.weatherforecast/
org.anddev.android.weatherforecast.WeatherForecast"));
intent.addCategory("android.intent.category.LAUNCHER");
startActivity(intent);
} 发布于 2011-07-19 22:41:26
试着从getLaunchIntentFromPackage获取你的意图:android doc
就像注释一样,您应该使用Intent.ACTION_MAIN而不是显式的字符串常量。
https://stackoverflow.com/questions/6748195
复制相似问题