Not sure I understand that. My manifest has three activities:

        <activity
            android:label="@string/app_name"
android:name=".WidgetDummyConfiguration">
            <intent-filter>
                <action
                    android:name="android.intent.action.MAIN" />
                <category
                    android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
         </activity>
        <activity
            android:label="@string/app_name"
android:name=".WidgetConfiguration">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <data android:scheme="com.vacuumpunk.CDTBD2012" />
                <category
android:name="android.intent.category.DEFAULT" />
            </intent-filter>
         </activity>
        <activity
            android:label="@string/app_name"
android:name=".WidgetInstall">
            <intent-filter>
                <action
 
android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
                <category
                    android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

The Activity WidgetDummyConfiguration is called when the APK has been
downloaded from the market and run. It does nothing (literally) - the
onCreate() method has only two lines of code:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        finish();
        }

The .WidgetInstall Activity is referenced in the widget config file
pointed to in the Manifest:

<appwidget-provider
    xmlns:android="http://schemas.android.com/apk/res/android";
    android:minWidth="294dp"
    android:minHeight="146dp"
    android:initialLayout="@layout/widget"
    android:configure= "com.vacuumpunk.CDTBD2012.WidgetInstall"
/>

When the user installs the Widget on the home screen, the
Activity .WidgetInstall is used and again it is invisible, but it does
do some setting up of default preferences and then just calls
finish(). That's to handle the bad use-cases that Android doesn't
handle so well.

My AppWidgetProvider then registers a PendingIntent on the click
listener for the RemoteView which fires up the third activity
(.WidgetConfiguration) which is the business part of the UI behind the
widget.

I guess what you mean is that the system must first run the invisible
do-nothing activity of .WidgetDummyInstall in order for the manifest
contents to be registered with the system which then means the Widget
will be entered into the list of available Widgets?

In my production code I actually present a basic dialog when the App
is run that explains how to install the Widget and then exits. The
user can only access my App's functionality via a home screen Widget.


On Feb 3, 8:42 am, Mark Murphy <[email protected]> wrote:
> On Thu, Feb 2, 2012 at 7:32 PM, David Ross <[email protected]> wrote:
> > Are you saying that does not work?
>
> It should not work, because the user can't add the app widget to bring
> up the configuration activity in the first place. The app widget does
> not appear in the launcher until the user has done something to bring
> your app out of the stopped state, such as launching an activity of
> yours from the launcher.
>
> It appears as though a reboot might also allow the app widget to show
> in the launcher, though I have not played with this scenario. A reboot
> definitely does not generally allow stopped apps to respond to
> broadcasts, though.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to *Advanced* Android Development_ Version 2.4
> Available!

-- 
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