0

I'm trying to make a home screen. I've got the widget to display but I need to send some kind of notify to it so it will start. Perhaps I'm missing something in the AndroidManifest.xml?

AndroidManifest.xml:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.Fredrik" android:versionCode="1" android:versionName="1.0">
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".HomeScreen" android:label="@string/app_name"
            android:launchMode="singleInstance" android:stateNotNeeded="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>
</manifest>

HomeScreen.java:

public class HomeScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final AppWidgetManager widgets = AppWidgetManager
            .getInstance(getApplicationContext());
    List<AppWidgetProviderInfo> installedProviders = widgets
            .getInstalledProviders();
    for (AppWidgetProviderInfo ws : installedProviders) {
        if (ws.label.startsWith("Music (Large)")) {
            AppWidgetHost h = new AppWidgetHost(getApplicationContext(), 10);
            int id = h.allocateAppWidgetId();
            AppWidgetHostView  v= h.createView(this, id, ws);
            setContentView(v);
            h.startListening();
            break;
        }
    }
}

}

Does anyone have a clue?

Verbeia
  • 4,400
  • 2
  • 23
  • 44
Fredrik Karlsson
  • 113
  • 1
  • 1
  • 9

1 Answers1

0

According to this post, you cannot program widget insertion yourself: http://groups.google.com/group/android-developers/browse_thread/thread/e4a5b4a87afcf707?pli=1

You have to call an intend that will give the user the ability to pick.

I was still surprised to hear you managed to get it to display...

Richard Lalancette
  • 2,401
  • 24
  • 29