Mahavir,

You should use the debugger to find out what happens in FBQueryAsyncTask.java on line 50. The next thing on the stack is Facebook API methods, which eventually crash with a null pointer exception.

A probable cause for this is that you're passing a null pointer to Facebook APIs from doInBackground. Use the debugger to confirm this and find out why this happens.

-- Kostya

19.03.2011 14:43, Mahavir Jain пишет:
No, I am not calling from onReceive() method of app-widget.

I will tell you step-by-step what I am doing:
1) There is my configuration Activity of my AppWidget class which perform the FB authentication and then retrieves the wall post using FBQueryAsyncTask. It do this successfully. 2) In my updateAppWidget() method, I update the remote views and assign the following pending intents to "next" button of my app-widget.

Intent intent=new Intent(context,GetPostService.class); //GetPostService is service class
        Bundle b=new Bundle();
        b.putInt(MyWidgetProvider.APP_WIDGET_ID, id);
b.putInt(MyWidgetProvider.REQUEST_CODE, MyWidgetProvider.NEXT_FB_POST);
        intent.putExtras(b);

PendingIntent nextPostService=PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        views.setOnClickPendingIntent(R.id.next_button, nextPostService);

3) In GetPostService, I am using the same FBQueryAsync class which I have used in configuration activity (to authenticate and retrieve the post) and with same parameter. But it throwing exception in my service class and it running perfectly in my configuration activity.

I may be missing something. Following is my ManifestXML where I have mentioned service, widget provider and cofiguration activity:

<activity android:name=".FBCredentialsActivity"
                    android:theme="@style/Theme.Transparent">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<receiver android:name="MyWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
                    android:resource="@xml/widget_provider"/>
</receiver>
<service android:name=".GetPostService"></service>

Thanks for giving time.

Regards,
Mahavir

On Sat, Mar 19, 2011 at 4:43 PM, Kostya Vasilyev <[email protected] <mailto:[email protected]>> wrote:

    19.03.2011 13:57, Mahavir Jain пишет:


        Is it valid to call AsyncTask from PendingIntent service or
        activity?


    AsyncTask has nothing to do with pending intents or activities.
    It's just a utility class.

    Check your logcat more carefully:


        ERROR/AndroidRuntime(473): Caused by:
        java.lang.NullPointerException
        ERROR/AndroidRuntime(473): at
        java.net.URLEncoder.encode(URLEncoder.java:53)
        ERROR/AndroidRuntime(473): at
        com.facebook.android.Util.encodeUrl(Util.java:86)
        ERROR/AndroidRuntime(473): at
        com.facebook.android.Util.openUrl(Util.java:146)
        ERROR/AndroidRuntime(473): at
        
com.mobisys.android.app_widget.FBQueryAsyncTask.doInBackground(FBQueryAsyncTask.java:50)


    Assuming that com.mobisys is your application, look in
    FBQueryAsync.java, line 50.

    Are you somehow calling Facebook classes with a NULL pointer?

    Are you using AsyncTask from a widget's onReceive?

-- Kostya Vasilyev -- http://kmansoft.wordpress.com



-- You received this message because you are subscribed to the Google
    Groups "Android Developers" group.
    To post to this group, send email to
    [email protected]
    <mailto:[email protected]>
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:android-developers%[email protected]>
    For more options, visit this group at
    http://groups.google.com/group/android-developers?hl=en


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to