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. How to get some GSM informations

Hi everybody
does anyone know how can I retrive some network information values.
I searched and got the api to get cellid and signal strength.
but I still don't know if I can get RXLEV, BSIC and BCCH using android
api.

thanks for help.

--~--~---------~--~----~------------~-------~--~----~

2. Access Java based WebService using Android

Hi ,

I developed my own web service for Searching purpose.But i wana to
access it using Android.
i tried some code but it does not work some exception are there as ::

 org.xmlpull.v1.XmlPullParserException: expected: END_TAG {http://
schemas.xmlsoap.org/soap/envelope/}Body (position:END_TAG </{http://
schemas.xmlsoap.org/soap/envelope/}env:Fault>@2:595 in
[EMAIL PROTECTED])

E/AndroidRuntime(  554):        at
org.kxml2.io.KXmlParser.exception(KXmlParser.java:243)

E/AndroidRuntime(  554):        at
org.kxml2.io.KXmlParser.require(KXmlParser.java:1374)

E/AndroidRuntime(  554):        at org.ksoap2.SoapEnvelope.parse(Unknown
Source)

E/AndroidRuntime(  554):        at
org.ksoap2.transport.Transport.parseResponse(Unknown Source)

E/AndroidRuntime(  554):        at
org.ksoap2.transport.AndroidHttpTransport.call(AndroidHttpTransport.java:
82)

E/AndroidRuntime(  554):        at
com.android.i3content.Test.playVideo(Test.java:74)

E/AndroidRuntime(  554):        at com.android.i3content.Test
$1.onClick(Test.java:56)

E/AndroidRuntime(  554):        at android.view.View.performClick(View.java:
1515)

E/AndroidRuntime(  554):        at
android.widget.ImageButton.performClick(ImageButton.java:80)

E/AndroidRuntime(  554):        at android.view.View.onKeyDown(View.java:
2280)

E/AndroidRuntime(  554):        at
android.view.KeyEvent.dispatch(KeyEvent.java:401)

E/AndroidRuntime(  554):        at
android.view.View.dispatchKeyEvent(View.java:2206)

E/AndroidRuntime(  554):        at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:360)

E/AndroidRuntime(  554):        at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:360)

E/AndroidRuntime(  554):        at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:360)

E/AndroidRuntime(  554):        at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:360)

E/AndroidRuntime(  554):        at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:360)

E/AndroidRuntime(  554):        at android.policy.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1071)

E/AndroidRuntime(  554):        at
android.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:884)

E/AndroidRuntime(  554):        at
android.app.Activity.dispatchKeyEvent(Activity.java:1377)

E/AndroidRuntime(  554):        at android.policy.PhoneWindow
$DecorView.dispatchKeyEvent(PhoneWindow.java:1058)

E/AndroidRuntime(  554):        at
android.view.ViewRoot.handleMessage(ViewRoot.java:564)

E/AndroidRuntime(  554):        at
android.os.Handler.dispatchMessage(Handler.java:80)

E/AndroidRuntime(  554):        at android.os.Looper.loop(Looper.java:71)

E/AndroidRuntime(  554):        at
android.app.ActivityThread.main(ActivityThread.java:2506)

E/AndroidRuntime(  554):        at
java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime(  554):        at
java.lang.reflect.Method.invoke(Method.java:380)

E/AndroidRuntime(  554):        at android.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:1170)

E/AndroidRuntime(  554):        at
android.os.ZygoteInit.main(ZygoteInit.java:1121)

E/AndroidRuntime(  554):        at android.dalvik.NativeStart.main(Native
Method)


I did not understand why these exception occured .can u plz suggest me
tht what can i do to resolve it.....i need suggestion ...
Thank u in advance ....wait for response....
--~--~---------~--~----~------------~-------~--~----~

3. In toast cancel()

4. Dial to a Number

5. application always persistent?

6. ID Handling between activities

7. I need the sample files for MOCK LOCATION PROVIDER