On the question of how to catch the exception:
try { GCMRegistrar.checkDevice(context); System.out.println("Device has GCM capabilities. So registering for GCM"); //// write code here to register for GCM } catch(Exception e) { System.out.println("Cannot cregister for GCM"); }
This is the logic to throw exceptions. Therefore, if any exception is thrown partially after the attempt, then the code partially after catch will be executed. checkDevice () throws an exception. If you do not catch the exception, the application will fail.
Also I don't think the syntax is all right, but this code will give you an idea of ββwhat to do.
Jagdeep sidhu
source share