1

I want to launch the stock weather app from my android app via an intent, but I keep getting a force close runtime error, and LogCat gives me nothing. The code I am trying to use to achieve this is:

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); 
} 
Alkema
  • 109
  • 2
  • 11

1 Answers1

0

Try to get your intent from getLaunchIntentFromPackage: android doc

just as a comment, you should use Intent.ACTION_MAIN instead of the explicit string constant.

Ran
  • 4,117
  • 4
  • 44
  • 70
  • OK, the problem was from using the wrong package for the app. But, using getLaunchIntentFromPackage was very helpful. – Alkema Jul 20 '11 at 00:21