So, assuming Android 1.5 is running on the phone I am planning on
doing the following:

Of course, the other fun thing about trying to test this is that I
can't buy my own friggin' app through the market.  I'm hoping others
can look at this code and help verify that checking for uninstalled
packages using the GET_UNINSTALLED_PACKAGES flag will do what I think
it will.

private Boolean isUserHasPaid = null;

private static final String DONATE_PACKAGE_NAME = "my.donate.package";

/**
 * Determines if a user has donated.
 *
 * This is determined by checking with the PackageManager and seeing
if the
 * donate app is currently installed, or if it is not installed, we'll
check to see
 * if they had it installed and uninstalled it.
 *
 * @param ctx The context
 *
 * @return true if user has donated, else false
 */

public boolean isUserHasPaid(Context ctx)
{
        if (isUserHasPaid == null)
        {
                PackageInfo pi = null;

                try
                {
                        pi = 
ctx.getPackageManager().getPackageInfo(DONATE_PACKAGE_NAME,
PackageManager.GET_ACTIVITIES);
                }
                catch (NameNotFoundException e)
                {
                        // Eat this exception - pi will be null if the package 
was not
found
                }

                if (pi == null)
                {
                        try
                        {
                                pi = 
ctx.getPackageManager().getPackageInfo(DONATE_PACKAGE_NAME,
PackageManager.GET_UNINSTALLED_PACKAGES);
                        }
                        catch (NameNotFoundException e)
                        {
                                // Eat this exception - pi will be null if the 
package was not
found
                        }
                }

                isUserHasPaid = Boolean.valueOf(pi != null);
        }

        return isUserHasPaid;
}

On Jul 22, 10:10 am, Mike <[email protected]> wrote:
> Hey there Mr Chaz!  :)
>
> Hmmm... I think I'm leaning towards just requiring people that buy my
> donate app to keep it on their phones and I'll look for it using the
> PackageManager as you suggested.
>
> I really don't want to deal with maintaining a web server and a
> backend database if I don't have to.  I'm making next to nothing off
> of this anyway, so the thought of spending yet more money on
> infrastructure seems a little premature at this point.
>
> - Mike
>
> On Jul 22, 5:30 am, MrChaz <[email protected]> wrote:
>
> > Assuming they still had it installed it you could just query the
> > PackageManager for it.
> > Otherwise I dunno, maybe it's possible to write stuff into the
> > SharedPreferences somehow
>
> > On Jul 21, 11:34 pm, Mike <[email protected]> wrote:
>
> > > Use case goes like this:
>
> > > 1) Dev puts game for sale on Android market hoping to make lots of $$
> > > $.
> > > 2) Dev makes $50 in a month, cries a little, realizes his game is
> > > languishing in the ratings so makes it free.
> > > 3) Game does really well and gets > 50,000 downloads.
> > > 4) Dev still wants to make some $$$ off his game, so adds a "donate"
> > > feature to app which points users to another app dev has created in
> > > the marketplace where they can donate by buying the app.
> > > 5) Dev wants to reward those who have donated by providing new
> > > features only to them.
>
> > > So...  how do I go about determining if any given user has purchased
> > > either my original app, or my "donate" app so that I can unlock
> > > functionality?  I'd like to determine this even if the user no longer
> > > has the app installed on their phone.
>
> > > Then android market app seems to know this which is how it knows not
> > > to charge the user again for the same app they've already paid for.
>
> > > - Mike
--~--~---------~--~----~------------~-------~--~----~
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