Preventing Multiple AppWidget Instances

by Jake Colman » Sun, 27 Feb 2011 10:45:17 GMT


Sponsored Links
 Is there a way to prevent multiple instances of an appwidget from being
installed on the home screen?  I do not do any special handling, nor is
it intended, for there to multiple instances.  Therefore, I should
probably prevent it or at least warn about it.  Is this possible?

-- 
Jake Colman -- Android Tinkerer

-- 



Preventing Multiple AppWidget Instances

by String » Sun, 27 Feb 2011 17:03:08 GMT


 There's no way to prevent it, no.

 IMHO, your best bet is to handle it gracefully: if the user wants to add 
multiple copies of your widget, let them. If that's not possible for whatever 
reason, then you will at least need to issue a warning. 

String 

-- 


Sponsored Links


Re: Preventing Multiple AppWidget Instances

by Jake Colman » Sun, 27 Feb 2011 22:25:15 GMT


 >>>>> "S" == String  <sterling.ud...@googlemail.com> writes:

   S> There's no way to prevent it, no.

   S>  IMHO, your best bet is to handle it gracefully: if the user wants
   S>  to add multiple copies of your widget, let them. If that's not
   S>  possible for whatever reason, then you will at least need to
   S>  issue a warning.

Can I detect that a second instance has been added so that I can display
a toast?

-- 
Jake Colman -- Android Tinkerer

-- 



Re: Re: Preventing Multiple AppWidget Instances

by Kostya Vasilyev » Sun, 27 Feb 2011 22:45:22 GMT


 Jake,

You can watch for ACTION_APPWIDGET_UPDATE with a previously unseen 
widget Id, or specify a configuration activity for the widget. The 
config activity can be made transparent and finish right away, so it's 
just there as a callback for your logic.


But if you do that, you've got to be really careful because of various 
edge cases and Android and launcher issues (also consider replacement 
launchers) .


Why not just let the user create as many widgets as they like, and let 
the user decide?


-- Kostya

27.02.2011 17:24, Jake Colman :
"S" == String<sterling.ud...@googlemail.com> writes:
S> There's no way to prevent it, no. S> IMHO, your best bet is to handle it gracefully: if the user wants S> to add multiple copies of your widget, let them. If that's not S> possible for whatever reason, then you will at least need to S> issue a warning. Can I detect that a second instance has been added so that I can display a toast?
-- Kostya Vasilyev -- http://kmansoft.wordpress.com --



Re: Preventing Multiple AppWidget Instances

by Jake Colman » Sun, 27 Feb 2011 23:09:03 GMT


 Thanks.  I guess nothing terrible will happen, it's just that it's not
useful.  Thanks.



   KV> Jake,

   KV> You can watch for ACTION_APPWIDGET_UPDATE with a previously
   KV> unseen widget Id, or specify a configuration activity for the
   KV> widget. The config activity can be made transparent and finish
   KV> right away, so it's just there as a callback for your logic.

   KV> But if you do that, you've got to be really careful because of
   KV> various edge cases and Android and launcher issues (also consider
   KV> replacement launchers) .

   KV> Why not just let the user create as many widgets as they like,
   KV> and let the user decide?

   KV> -- Kostya

   KV> 27.02.2011 17:24, Jake Colman :
   >>>>>>> "S" == String<sterling.ud...@googlemail.com>  writes:
   S> There's no way to prevent it, no.
   >> 
   S> IMHO, your best bet is to handle it gracefully: if the user wants
   S> to add multiple copies of your widget, let them. If that's not
   S> possible for whatever reason, then you will at least need to
   S> issue a warning.
   >> 
   >> Can I detect that a second instance has been added so that I can display
   >> a toast?
   >> 

   KV> -- 
   KV> Kostya Vasilyev --  http://kmansoft.wordpress.com 

   KV> -- 
   KV> 

-- 
Jake Colman -- Android Tinkerer

-- 



Other Threads

1. Android tasks and activities

I've got an application that has a number of activities.  One of the
things that it can do is create a shortcut on the homescreen that when
pressed starts an activity inside my application.  I am finding
however that there's an issue with how tasks are working and screens
that I don't expect to be shown are shown.

Here's my situation:

1) I am running activity A of my application in the foreground
2) I press the home key and move back to the home screen
3) I start a shortcut which starts activity B of my application'
4) From within activity B I press the back button
5) ******ACTIVITY A IS SHOWN AND NOT THE HOME SCREEN****************

would like to see the home screen rather than activity A since
activity A is very independent of activity B and seeing it again is
not what they'd expect.

What can be done to ensure that pressing back on activity B at step 5
above shows the home screen again rather than activity A

Thanks
Lee
--~--~---------~--~----~------------~-------~--~----~

2. new'ing an Intent

In the notepad2.java example, the sample allocates an intent like
this:

    private void createNote() {
        // TODO: fill in implementation
        Intent i = new Intent(this, NoteEdit.class);
        startActivityForResult(i, ACTIVITY_CREATE);
    }

I effectively copied that code, changed it fit for me, but it does not
"compile" with error constructor doesn't exist.  The "quick fix"
according to Eclipse is to remove the parameters.  I'm confused....any
help would be appreciated....

package com.bigwoo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;


// startup screen
public class WelcomeScreen extends Activity
{
    private static final int ACTIVITY_GAMEON=0;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button button = (Button) findViewById(R.id.startgameBtnId);
        button.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {
                Intent startGameIntent = new Intent(this,
RootGameScreen.class);
                startActivityForResult(startGameIntent,
ACTIVITY_GAMEON);
            }
        });

    }
}
--~--~---------~--~----~------------~-------~--~----~

3. No security mechanism to protect again reflection

4. Can other applications use the share function of "Facebook for Android"?

5. make a SurfaceView visible/invisible at runtime

6. Help me: My emulator reported an error that "com.android.settings has no certificates at entry AndroidManifest.xml"

7. How to install EAP TLS certificates for WiF