• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Error Loading Widget

My widget juts says problem loading widget when i try to load it and i have no idea why, I'm really new to andriod dev so any help would be appreciated. I literally have no idea what it is as there is no logcat error :/

Manifest:

Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="kevin.erica.box"
android:versionCode="1"
android:versionName="1.1">

<uses-sdk android:minSdkVersion="10" />

<application
    android:icon="@drawable/menuiconerica"
    android:label="@string/app_name" 
    android:screenOrientation="portrait"
    android:theme="@android:style/Theme.Light.NoTitleBar">
    <activity
        android:name=".TheKevinAndEricaBoxActivity"
        android:label="@string/app_name" 
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="App2Activity"
        android:screenOrientation="portrait"> </activity>
    <activity android:name="MobileArrayAdapter"></activity>

    <receiver android:name=".Widget" android:label="Erica's Box">
    <intent-filter>
    <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
   </intent-filter>
  <meta-data android:name="android.appwidget.provider" android:resource="@xml/erica_info" />
</receiver>
    </application>

</manifest>
Widget activity:

Code:
 package kevin.erica.box;

import java.util.Arrays;
import java.util.Random;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.widget.RemoteViews;



public class Widget extends AppWidgetProvider {




private static final Random rgenerator = new Random();
private static final Random rgenerator2 = new Random();
private String[] myString1;






  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
      Resources res = context.getResources();
        if (myString1 == null)
        {
            myString1 = res.getStringArray(R.array.myArray);
        }
    final int N = appWidgetIds.length;
    Log.i("ExampleWidget",  "Updating widgets " + Arrays.asList(appWidgetIds));
    // Perform this loop procedure for each App Widget that belongs to this
    // provider
    for (int i = 0; i < N; i++) {
      int appWidgetId = appWidgetIds[i];
      // Create an Intent to launch ExampleActivity
      Intent intent = new Intent(context, Widget.class);
      PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
      // Get the layout for the App Widget and attach an on-click listener
      // to the button
      RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widgetlayout);
      views.setOnClickPendingIntent(R.id.imagewidgeterica, pendingIntent);
      // To update a label
      views.setTextViewText(appWidgetId, myString1[rgenerator.nextInt(myString1.length)]);
      // Tell the AppWidgetManager to perform an update on the current app
      // widget
      appWidgetManager.updateAppWidget(appWidgetId, views);
    }
  }
}
 
Back
Top Bottom