0

I'm looking for the simplest way to write a boolean function that will tell me if the device the app is running on is capable of using C2DM.

I am aware that the presence of the Android Google Play app is guaranteed to ensure C2DM capability but not all devices have this and are still C2DM capable

As far as I can tell, The device needs to have the GSF installed (Google Services Framework) and a valid GMail account set up and these are the only requirements to guarantee C2DM will work. Is this accurate?

If so would a check for the existence of the GMail package and the Google Services Framework package be the best and most accurate approach?

jamesc
  • 12,423
  • 15
  • 74
  • 113
  • Could you not do a check for the presence of the google play store? – Broak May 29 '12 at 11:51
  • @xBroak, As mentioned in my question "I am aware that the presence of the Android Google Play app is guaranteed to ensure C2DM capability but not all devices have this and are still C2DM capable" – jamesc May 29 '12 at 11:53
  • "but not all devices have this and are still C2DM capable" -- such as? – CommonsWare May 29 '12 at 11:56
  • @CommonsWare - Devices that have the GSF installed? Your "Such as?" question makes me think that maybe Google Play package is the only requirement for C2DM? – jamesc May 29 '12 at 12:00
  • You make it sound like that you have seen devices that have GSF (and C2DM capability) and do not have Google Play. I am not aware of any, so I was curious as to which devices you saw that had this configuration. The only thing that matches that description, that I am aware of, is the Android emulator. – CommonsWare May 29 '12 at 12:12
  • @CommonsWare No, I am not aware of any, just that it may be possible especially as there are so many android device manufacturers out there and a huge range of devices. I'm happy to stand corrected on this especially as it would make my life a lot simpler :) – jamesc May 29 '12 at 12:24

1 Answers1

1

Very quick an dirty but the concept remains, if you DO wish to simply search for the presence of the Google services framework you can use the below.

I only post this because AFAIK there isn't another obvious method.

 boolean installed  =   appInstalledOrNot("com.google.process.gapps");
        if(installed)
        {
                  System.out.println("App installed on phone");
        }
        else
        {
            System.out.println("App is not installed phone");
        }
    }
    private boolean appInstalledOrNot(String uri)
    {
        PackageManager pm = getPackageManager();
        boolean app_installed = false;
        try
        {
               pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
               app_installed = true;
        }
        catch (PackageManager.NameNotFoundException e)
        {
               app_installed = false;
        }
        return app_installed ;
}
Broak
  • 4,161
  • 4
  • 31
  • 54