I followed the tutorial off code.google.com to add widgets to your
app. For some reason, when I run the app on the phone for testing,
then long click the home screen to add widgets, my widget is not an
option. I imagine I am doing something wrong, but I thought I followed
the tutorial pretty well. Here is some of my code, please offer a
suggestion of why I can't add my widget. BTW i dont care that it
doesnt do anything yet, or even if it breaks, I just want to see it as
an option first (small steps). Thanks for any help or feedback

Any * you see, is just a place holder for the real name.

My widget provider

public class * extends AppWidgetProvider {

    public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[] appWidgetIds) {
        final int N = appWidgetIds.length;

        // 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, MobileApp.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.widget);
            views.setOnClickPendingIntent(R.id.widget_next_label,
pendingIntent);

            // Tell the AppWidgetManager to perform an update on the
current App Widget
            appWidgetManager.updateAppWidget(appWidgetId, views);
        }
    }
}


My manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
      package="com.*.android"
      android:versionCode="1"
      android:versionName="1.0.0">

  <application
    android:label="*">

    <activity
      android:name=".MobileApp"
      android:label="*"
      android:configChanges="orientation|keyboardHidden"
      android:theme="@style/Theme.NoBackground"
      android:icon="@drawable/icon_gs">
      <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
                </activity>
    <service android:name=".audio.AudioPlayerService"
android:exported="false" android:enabled="true" />
  </application>

<receiver android:name=".*AppWidgetProvider" android:label="* Widget">
    <intent-filter>
        <action
android:name="android.appwidget.action.APPWIDGET_UPDATE" />
    </intent-filter>
    <meta-data android:name="android.appwidget.provider"
               android:resource="@xml/app_widget_info" />
</receiver>



  <uses-sdk minSdkVersion="2" />
        <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.READ_PHONE_STATE"/
>
  <uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.WAKE_LOCK"/>
</manifest>


and my info .xml file...


<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/
android"
    android:minWidth="294dp"
    android:minHeight="72dp"
    android:updatePeriodMillis="86400000"
    android:initialLayout="@layout/widget" >
</appwidget-provider>


my widget layout file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android";
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

        <Button
                android:id="@+id/widget_play_button"
                android:layout_width="25px"
                android:layout_height="25px"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:text="Play"     />

        <Button
                android:id="@+id/widget_next_button"
                android:layout_width="25px"
                android:layout_height="25px"
                android:layout_toRightOf="@id/widget_play_button"
                android:text="Next" />

        <TextView
                android:id="@+id/widget_song_label"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/widget_next_button"
                android:layout_marginTop="5px"
                android:text="Song Name by Song Artist"
                android:textSize="16px"/>

        <TextView
                android:id="@+id/widget_next_label"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/widget_next_button"
                android:layout_below="@id/widget_song_label"
                android:layout_marginTop="5px"
                android:textSize="10px"
                android:text="Next Song by Next Artist"/>

</RelativeLayout>
--~--~---------~--~----~------------~-------~--~----~
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