GeorgeP
GeorgeP

Reputation: 21

keep getting these error messege "The method onCreate(Bundle) is undefined for the type AppWidgetProvider"

The method onCreate(Bundle) is undefined for the type AppWidgetProvider

public class SupermarioActivity<imageButton1> extends AppWidgetProvider {
public static SupermarioActivity Widget = null;
public static Context context;
public static AppWidgetManager appWidgetManager;
public static int appWidgetIds[];   

@Override
public void onUpdate( Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds )    {     
    if (null == context) context = SupermarioActivity.context;
    if (null == appWidgetManager) appWidgetManager = SupermarioActivity.appWidgetManager;
    if (null == appWidgetIds) appWidgetIds = SupermarioActivity.appWidgetIds;

    SupermarioActivity.Widget = this;
    SupermarioActivity.context = context;
    SupermarioActivity.appWidgetManager = appWidgetManager;
    SupermarioActivity.appWidgetIds = appWidgetIds;

    Log.i("PXR", "onUpdate");


    }

static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
        int appWidgetId) {


    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
    remoteViews.setImageViewResource(R.id.imageButton1, appWidgetId);


    // Tell the widget manager
    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}

  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);    

    imageButton1 imagebutton1 = (imageButton1) findViewById(R.id.imageButton1);

    imageButton1.setOnClickListener(new OnClickListener()
    {
      public void onClick(View v)
      {
         ImageView iv = (ImageView) findViewById(R.id.imageview1);
         iv.setVisibility(View.VISIBLE);
      }
    });
}

    private void setContentView(int main) {
    // TODO Auto-generated method stub

}
    private imageButton1 findViewById(int imagebutton1) {
    // TODO Auto-generated method stub
    return null;
}

}

Upvotes: 0

Views: 2410

Answers (3)

akemalFirdaus
akemalFirdaus

Reputation: 606

Just put extends Activity on your class

Upvotes: 0

Ted Hopp
Ted Hopp

Reputation: 234795

You defined an onCreate(Bundle) method for SupermarioActivity<imageButton1> that looks like it belongs in an Activity subclass. But SupermarioActivity extends AppWidgetProvider, not Activity (or any Activity subclass).

Upvotes: 2

Nanne
Nanne

Reputation: 64399

I believe it's pretty straightforward: the class AppWidgetProvider does not seem to have a method onCreate(Bundle).

A convenience class to aid in implementing an AppWidget provider. Everything you can do with AppWidgetProvider, you can do with a regular BroadcastReceiver. AppWidgetProvider merely parses the relevant fields out of the Intent that is received in onReceive(Context,Intent), and calls hook methods with the received extras.

(emph mine, from http://developer.android.com/reference/android/appwidget/AppWidgetProvider.html )

If I was a paperclip, I might have posted:

It looks like you are trying to make an Activity? Would you like to:
- Extend the activity class?

Upvotes: 1

Related Questions