Widget setOnClickPendingIntent not working

by Kasra Rahjerdi » Mon, 08 Mar 2010 12:20:20 GMT


Sponsored Links
 Hello,
I have a simple widget and I'm trying to pop up another activity when
it's clicked. My widget is not focusable or clickable even though in
the XML layout I explicity set it to be and when my widget is clicked
nothing happens.

My manifest has:
<receiver android:name=".WidgetConfigurator" android:label="@string/
app_name">
            <intent-filter>
                <action
android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget" />
        </receiver>

My layout is:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=" http://schemas.android.com/apk/res/ 
android"
    android:id="@+id/widgetlayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/widget_background"
    android:paddingLeft="19dip"
    android:paddingTop="21dip"
    android:clickable="true"
    android:focusable="true" >

        <TextView android:id="@+id/widgettext"
            android:text="Click here to set the text."
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_alignParentLeft="true"
            android:maxWidth="284dip"
            android:maxHeight="58dip"
            android:textSize="12dip"
            android:textColor="@android:color/black"
            />

</RelativeLayout>

And my AppWidgetProvider's onUpdate code contains:
        @Override
        public void onUpdate(Context ctx, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
                if(man == null)
                        onEnabled(ctx);

                Log.i(TAG, "Updating");
                RemoteViews updateViews = new RemoteViews(ctx.getPackageName(),
R.layout.widget);

                Random rand = new Random();
                for(int k = 0; k < appWidgetIds.length; k++) {
                int i = rand.nextInt(count);

                Intent intent = new Intent(ctx, WidgetClick.class);
                        PendingIntent pendingIntent = 
PendingIntent.getBroadcast(ctx, 0,
intent, 0);

                updateViews.setOnClickPendingIntent(R.id.widgetlayout,
pendingIntent);
                        updateViews.setTextViewText(R.id.widgettext,
storiesArray.get(i));

                        appWidgetManager.updateAppWidget(appWidgetIds, 
updateViews);
                }
        }


Everything in my onUpdate works perfectly other than the
setOnClickPendingIntent command. Am I doing something wrong?

--



Widget setOnClickPendingIntent not working

by String » Mon, 08 Mar 2010 19:07:48 GMT


 On Mar 8, 4:20am, Kasra Rahjerdi <johncena4presid...@gmail.com>




Try changing your PendingIntent.getBroadcast() call to a
getActivity(). If you're trying to start an activity, that would seem
to make more sense - and that's what works for my appwidgets.

String

--


Sponsored Links


Widget setOnClickPendingIntent not working

by Kasra Rahjerdi » Tue, 09 Mar 2010 02:22:00 GMT


 Good catch! Thank you. I've fixed this yet it has made no difference.
I can not even focus onto my widget and clicking it doesn't show any
highlight or anything either.





--



Widget setOnClickPendingIntent not working

by Kasra Rahjerdi » Thu, 11 Mar 2010 09:47:43 GMT


 I've made some progress. If I set my application up to do widget
updating in onRecieve everything works, similar code in the onUpdate
function does not.

--



Other Threads

1. The website gets thousands of peoples' approval.

My father always want to buy a Nokia telephone, he think it will make his
life much easyier and funny. But for preparing my graduation gift, he give
up it after several viewing on it. To give my father a surprised, I intend
to send him the one he like most. I intend to buy it on
www.21newgoods.com

-- 

2. Digest for android-security-discuss@googlegroups.com - 2 Messages in 2 Topic

Anders, I could not agree more...
Keystore, attestation (both ways) are quite important. There must be an
interest for a unified set of APIs for apps for this purpose  in
Android.ving
Please forgive my ignorance here, where is your project today, what kind of
traction is there.
Do you mind giving me a brief update....

Regards,
PC


On Wed, Oct 6, 2010 at 1:36 PM, <
android-security-discuss+nore...@googlegroups.com<android-security-discuss%2bnore...@googlegroups.com>



> Group: 

3. best way to play 10 sounds quickly

4. bring task to front

5. Acclerating Graphics Using CopyBit on froyo.

6. 鍥炲: Java and Android phone s?

7. 鍥炲: Problem with ListView on a 480x854 device