Skip to content

Commit 509e2fd

Browse files
authored
Merge pull request #359 from Backendless/oleg.vyalyh/18043/FCM_when_app_kill
BKNDLSS-18043 [SUPPORT] NullPointerException in BackendlessFCMService…
2 parents 6fd5871 + fe610de commit 509e2fd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/com/backendless/Backendless.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ private static boolean isAndroidEnvironment()
9696
Log.removeLogger( ILoggingConstants.DEFAULT_LOGGER );
9797
prefs = BackendlessPrefsFactory.create( isAndroid );
9898
if( isAndroid )
99+
{
100+
prefs.onCreate( ContextHandler.getAppContext() );
99101
Media = com.backendless.Media.getInstance();
102+
}
100103

101104
AmfV3Formatter.AddTypeWriter( QueryOptions.class, new ITypeWriter()
102105
{
@@ -120,6 +123,17 @@ public boolean isReferenceableType()
120123
return false;
121124
}
122125
} );
126+
127+
try
128+
{
129+
if( !initialized && prefs.getApplicationId() != null && prefs.getApiKey() != null )
130+
Backendless.initApplicationFromProperties( ContextHandler.getAppContext() );
131+
}
132+
catch( IllegalStateException e )
133+
{
134+
if( !ExceptionMessage.NOT_INITIALIZED.equals( e.getMessage() ) )
135+
throw e;
136+
}
123137
}
124138

125139
public static boolean isAndroid()
@@ -202,7 +216,7 @@ public static void initApp( Object context, final String applicationId, final St
202216
Class realmObjectClass = Class.forName( "io.realm.RealmObject" );
203217
BackendlessSerializer.addSerializer( realmObjectClass, new RealmSerializer() );
204218
}
205-
catch( Throwable t )
219+
catch( Throwable ignore )
206220
{
207221

208222
}

0 commit comments

Comments
 (0)