Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass an Arraylist from Activity to Widget
    primarykey
    data
    text
    <p>I am trying to pass an arraylist from activity to widget but my app crushes at the my widget provider.</p> <p>I gave details below.</p> <p>Here is part of code from my first activity:</p> <pre><code> Intent intent1 = new Intent(MainActivity.this, AppProviderWidget.class); intent1.setAction("android.appwidget.action.APPWIDGET_UPDATE"); // Use an array and EXTRA_APPWIDGET_IDS instead of // AppWidgetManager.EXTRA_APPWIDGET_ID, // since it seems the onUpdate() is only fired on that: int[] ids = widgetIDs; intent1.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); intent1.putExtra("widgetlist", result); sendBroadcast(intent1); </code></pre> <p><strong>I sent data is here :</strong></p> <pre><code> intent1.putExtra("widgetlist", result); </code></pre> <p><strong>And code from the AppProviderWidget onReceive method</strong></p> <pre><code> @Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); ArrayList&lt;DuyuruHaber&gt; arl = new ArrayList&lt;DuyuruHaber&gt;(); arl = (ArrayList&lt;DuyuruHaber&gt;) intent .getSerializableExtra("widgetlist"); try { liste = arl; } catch (Exception e) { Log.w("Log",e.toString()); }} </code></pre> <p><strong>AppProviderWidget.onReceive(AppProviderWidget.java:170)</strong></p> <pre><code>arl = (ArrayList&lt;DuyuruHaber&gt;) intent .getSerializableExtra("widgetlist"); </code></pre> <p><strong>my log cat</strong></p> <pre><code>08-23 16:28:01.684: E/AndroidRuntime(10067): FATAL EXCEPTION: main 08-23 16:28:01.684: E/AndroidRuntime(10067): java.lang.RuntimeException: Unable to start receiver widget.AppProviderWidget: java.lang.NullPointerException 08-23 16:28:01.684: E/AndroidRuntime(10067): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821) 08-23 16:28:01.684: E/AndroidRuntime(10067): at android.app.ActivityThread.access$3200(ActivityThread.java:125) 08-23 16:28:01.684: E/AndroidRuntime(10067): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083) 08-23 16:28:01.684: E/AndroidRuntime(10067): at android.os.Handler.dispatchMessage(Handler.java:99) 08-23 16:28:01.684: E/AndroidRuntime(10067): at android.os.Looper.loop(Looper.java:123) 08-23 16:28:01.684: E/AndroidRuntime(10067): at android.app.ActivityThread.main(ActivityThread.java:4627) 08-23 16:28:01.684: E/AndroidRuntime(10067): at java.lang.reflect.Method.invokeNative(Native Method) 08-23 16:28:01.684: E/AndroidRuntime(10067): at java.lang.reflect.Method.invoke(Method.java:521) 08-23 16:28:01.684: E/AndroidRuntime(10067): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) 08-23 16:28:01.684: E/AndroidRuntime(10067): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 08-23 16:28:01.684: E/AndroidRuntime(10067): at dalvik.system.NativeStart.main(Native Method) 08-23 16:28:01.684: E/AndroidRuntime(10067): Caused by: java.lang.NullPointerException 08-23 16:28:01.684: E/AndroidRuntime(10067): at widget.AppProviderWidget.onReceive(AppProviderWidget.java:170) 08-23 16:28:01.684: E/AndroidRuntime(10067): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810) </code></pre> <p><em>Thanks for the help.</em></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload