Weird onclick behavior of images on home screen widget
- by kknight
I wrote a home screen widget with one image on it. When the image is clicked, browser will be opened for a url link.
Generally, it is working. But a weird thing is that, when I click background, then click the picture, the browser will not be open. Until I click the second time on the picture, the browser opens. The steps to reproduce is below:
Click on the home screen widget background.
Click on the image on the home screen. The browser is not opened.
Click on the image again. The browser is opened.
If I didn't click on the background, the image will react to click very well, i.e. browser will be open when the image is clicked the first time.
The widget XML file is as below:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="320dip" android:layout_height="200dip"
android:background="@drawable/prt_base"
>
<ImageView android:id="@+id/picture1"
android:layout_width="134dip"
android:layout_height="102dip"
android:layout_marginLeft="62dip"
android:layout_marginTop="6dip"
android:scaleType="center"
android:src="@drawable/picture1"
/>
</RelativeLayout>
The code to set OnClick on the picture1 ImageView is as below:
defineIntent = new Intent(Intent.ACTION_VIEW, Uri
.parse("http://www.google.com"));
pendingIntent = PendingIntent
.getActivity(context,
0 /* no requestCode */,
defineIntent, 0 /* no flags */);
updateViews.setOnClickPendingIntent(
picId, pendingIntent);
Anyone knows what's wrong?
Thanks.