The method startActivity(Intent) is undefined for the type?

前端 未结 2 695
北荒
北荒 2021-01-16 17:18

So im trying to start an activity by pressing a widget. I keep running into the error \"The method startActivity(Intent) is undefined for the type Photos\" any help is much

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-16 17:37

    What method have you put this code in? AppWidgetProvider does not have a startActivity() method. You need a Context for that. Several of AppWidgetProvider's callback methods give you access to a Context object, but it all really depends on what you intend to do.

    I suggest you take a look at the Android developer guide's documentation on AppWidgets here.

提交回复
热议问题