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 appreciated! My class code is below:
package com.natehoch96.widgets.iOS;
import android.appwidget.AppWidgetProvider;
import android.content.Intent;
public class Photos extends AppWidgetProvider {
Intent myIntent = new Intent(android.provider.Settings.ACTION_SETTINGS);
{startActivity(myIntent); }
}
You need to implement the onUpdate() and onReceive() methods in your AppWidgetProvider class, something like this:
Then write your onReceive() method to receive the pending intent and start the relevant activity: