We will focus on learning how to construct an Activity class in AndroidWidget development. The Activity class in this example is very similar to a common Activity, but it needs to be processed after loading the Activity information in the trigger function.
AndroidWidget Development
Construct Activity Class
In this example, the Activity class in AndroidWidget development is very similar to the ordinary Activity, but it needs to be processed more after loading the Activity information in the trigger function.
(1) Add the following statement at the end of the onCreate (Bundlebundle) function. The intention is to save mAppWidgetId and pass it to AppWidgetProvider:
Java code:
Intentintent = getIntent (); Bundleextras = intent. getExtras (); if (extras! = Null) {mAppWidgetId = extras. getInt (AppWidgetManager. EXTRA_APPWIDGET_ID, AppWidgetManager. INVALID_APPWIDGET_ID );
}
If (mAppWidgetId = AppWidgetManager. INVALID_APPWIDGET_ID ){
Finish ();
}