I’m logging to bank account and getting account balance.
I calling this function from onUpdate in widget and running in AsyncTask
package com.example.oobe.widget.widgetexample;
public class ExampleAppWidgetProvider extends AppWidgetProvider
{
(...)
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
{
(...)
if (notFromAsyncTask)
new MyAsyncTask().execute(context);
(...)
}
(...)
}
In method onPostExecute I want to call onUpdate widget and putExtra strings.
How can I do this?
package com.example.oobe.widget.widgetexample;
public class MyAsyncTask extends AsyncTask<Object, Void, BGZ>
{
Context context;
@Override
protected BGZ doInBackground(Object... params)
{
this.context = (Context)params[0];
return GetSomething();
}
protected void onPostExecute(BGZ page)
{
Intent intent = new Intent(context, ExampleAppWidgetProvider.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent.putExtra("result", result);
intent.putExtra("webpage", webPage);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
(...)
}
If I doing like above I’m getting error:
.. Unable to find explicit activity class..
Can I do this from AsyncTask?
Can I call widget_update (onUpdate) with params to recognize that is from my AsyncTask?
Please give me little sample code (what to add to manifest if it must be broadcastreceiver and so on).
I have updated widget in onPostExecute but I think better method is to do that in ExampleAppWidgetProvider class?
If you are getting this error
It may be due to this line
make sure ExampleAppWidgetProvider.class exist and
or
UPDATE