通过Intent启动Android Weather App

时间:2011-07-19 13:48:33

标签: android android-intent

我想通过我的Android应用程序启动股票天气应用程序 意图,但我一直得到一个强制关闭运行时错误,和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); 
} 

1 个答案:

答案 0 :(得分:0)

尝试从getLaunchIntentFromPackage获取您的意图: android doc

作为注释,您应该使用Intent.ACTION_MAIN而不是显式字符串常量。