mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
don't crash on emulator (which doesn't have library required by GCM)
This commit is contained in:
parent
03108f311a
commit
41cfacfee4
1 changed files with 17 additions and 13 deletions
|
@ -60,20 +60,24 @@ public class GCMIntentService extends GCMBaseIntentService {
|
|||
DbgUtils.logf( "GCMIntentService.init()" );
|
||||
int sdkVersion = Integer.valueOf(android.os.Build.VERSION.SDK);
|
||||
if ( 8 <= sdkVersion ) {
|
||||
GCMRegistrar.checkDevice( app );
|
||||
GCMRegistrar.checkManifest( app );
|
||||
final String regId = GCMRegistrar.getRegistrationId( app );
|
||||
if (regId.equals("")) {
|
||||
DbgUtils.logf( "registering..." );
|
||||
GCMRegistrar.register( app, GCMConsts.SENDER_ID );
|
||||
} else {
|
||||
DbgUtils.logf( "Already registered: id=\"%s\"", regId );
|
||||
}
|
||||
try {
|
||||
GCMRegistrar.checkDevice( app );
|
||||
GCMRegistrar.checkManifest( app );
|
||||
final String regId = GCMRegistrar.getRegistrationId( app );
|
||||
if (regId.equals("")) {
|
||||
DbgUtils.logf( "registering..." );
|
||||
GCMRegistrar.register( app, GCMConsts.SENDER_ID );
|
||||
} else {
|
||||
DbgUtils.logf( "Already registered: id=\"%s\"", regId );
|
||||
}
|
||||
|
||||
String curID = XWPrefs.getGCMDevID( app );
|
||||
if ( ! curID.equals( regId ) ) {
|
||||
DbgUtils.logf( "saved bad id: %s", curID );
|
||||
XWPrefs.setGCMDevID( app, regId );
|
||||
String curID = XWPrefs.getGCMDevID( app );
|
||||
if ( ! curID.equals( regId ) ) {
|
||||
DbgUtils.logf( "saved bad id: %s", curID );
|
||||
XWPrefs.setGCMDevID( app, regId );
|
||||
}
|
||||
} catch ( UnsupportedOperationException uoe ) {
|
||||
DbgUtils.showf( app, "Device can't do GCM; am I on an emulator?" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue