Programmatically Create/Destroy AppWidgets

Showing 1-7 of 7 messages
Programmatically Create/Destroy AppWidgets Tanay Shah 3/4/10 11:04 PM
Hey,

Is it possible to programmatically create and/or destroy AppWidgets?

Re: Programmatically Create/Destroy AppWidgets ik 3/7/10 12:44 PM
Here is an example to create a button :

[code]
public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayout layout = new LinearLayout(this);
        layout.setLayoutParams(new
LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        Button button = new Button(this);
        button.setLayoutParams(new
LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        button.setText("my button");

        layout.addView(button);
        setContentView(layout);
    }
}
[/code]

On 5 mar, 08:04, Tanay Shah <tanay.s...@gmail.com> wrote:
> Hey,
>
> Is it possible to programmatically create and/or destroy AppWidgets?

Re: [android-developers] Re: Programmatically Create/Destroy AppWidgets Mark Murphy 3/7/10 12:46 PM
ik wrote:
> Here is an example to create a button :

The OP asked about app widgets (a.k.a., home screen widgets), not
widgets for use in activities.

>> Is it possible to programmatically create and/or destroy AppWidgets?

No. Users have to add and remove app widgets.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

Re: Programmatically Create/Destroy AppWidgets shaun 3/8/10 12:29 PM
Not sure if this is what you are going for....

It is possible to have a single APK install that has a main Activity
component as well as a Widget.  I saw a demo where the .apk file is
installed, you can open the Activity as a normal application and on
the home screen(s) add a Widget from that application.  The Widget in
this case was just a shortcut to open the application in a certain
spot for convenience (i.e. bookmark).

I guess this was accomplised through the contents of
AndroidManifest.xml where the main Activity was defined along with a
Widget.  Not too familiar with Widgets yet, so maybe this is common
knowledge.

I wish I could track down the guy who showed me that as I would like
to do the same thing.  Although, all the information on how to do this
might be easily located in the documentation.  I have not looked much,
but will start to soon.

On Mar 7, 3:46 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> ik wrote:
> > Here is an example to create a button :
>
> The OP asked about app widgets (a.k.a., home screen widgets), not
> widgets for use in activities.
>
> >> Is it possible to programmatically create and/or destroy AppWidgets?
>
> No. Users have to add and remove app widgets.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy

>
> Android Training...At Your Office:http://commonsware.com/training

Re: Programmatically Create/Destroy AppWidgets Rok Arnus 3/12/10 8:30 AM
I would also like to know, how to add a widget to the home screen
programmatically.The idea is, that the app would ask the user, if he
would also like a widget.
Re: [android-developers] Re: Programmatically Create/Destroy AppWidgets TreKing 3/12/10 10:40 PM
On Fri, Mar 12, 2010 at 10:30 AM, Rok Arnus <rok....@gmail.com> wrote:
I would also like to know, how to add a widget to the home screen
programmatically.The idea is, that the app would ask the user, if he
would also like a widget.

Already answered in this very thread:

On Sun, Mar 7, 2010 at 2:46 PM, Mark Murphy <mmu...@commonsware.com> wrote:
>> Is it possible to programmatically create and/or destroy AppWidgets?

No. Users have to add and remove app widgets.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking
Re: Programmatically Create/Destroy AppWidgets Paul Turchenko 3/13/10 4:54 AM
App widgets (home screen widgets) live in separate process and you
have no control on adding/removing them. All you can do is tell in
your AndroidManifest.xml that you have a new appwidget and user will
seen it when he decides to place something to his homescreen.