Launching Android Weather App Via Intent

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("")); intent.addCategory("android.intent.category.LAUNCHER"); startActivity(intent); }


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.

人吐槽 人点赞



用户名: 密码:
验证码: 匿名发表


查看评论:Launching Android Weather App Via Intent