AppWidgetProvider handle touch event problem
i am adding installed AppWidgetViews to my application as AppWidgetHostView. The problem is they don't handle any touch events as they were added to home screen. Here is part of my code;
AppWidgetHost host = new AppWidgetHost(getContext(), HOST_ID);
AppWidgetManager manager = AppWidgetManager.getInstance(getContext());
int id = host.allocateAppWidgetId();
AppWidgetHostView view = host.createView(getContext(), id, info);
Lets say AppWidgetProviderInfo object "info" belongs to "com.android.alarmclock.AnalogAppWidgetProvider", which is the default ana开发者_开发知识库log clock widget of android. This view has to launch clock setting when a click performed on it as it performed on home screen, still i have no response from it. Is there a way to solve this problem? Thanks in advance...
I am not sure this will answer your question.
To handle onClick event in android homescreen, I use PendingIntent to setOnClick behavior.
Intent iText = new Intent(this, urTargetActivity.class);
PendingIntent pendingText = PendingIntent.getActivity(context,0, iText,0);
views.setOnClickPendingIntent(R.id.textView1,pendingText);
I am not sure about using it with AppWidgetHostView but the way I have done before is using it in the service to call the configuration activity page which is working without any problem.
Hope this could help you somehow :)
精彩评论