Skip to content

Commit cdc64d9

Browse files
committed
Handle a null bundle which actually usually in the place
1 parent 9a9659b commit cdc64d9

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

ReactiveUI/Android/BundleSuspensionDriver.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ public BundleSuspensionDriver()
2121
public IObservable<object> LoadState()
2222
{
2323
try {
24-
return Observable.Return(JsonConvert.DeserializeObject(
25-
AutoSuspendActivityHelper.LatestBundle.GetString("__state"),
26-
SerializerSettings));
24+
// NB: Sometimes OnCreate gives us a null bundle
25+
if (AutoSuspendActivityHelper.LatestBundle == null) {
26+
return Observable.Return(default(object));
27+
}
28+
29+
var ret = JsonConvert.DeserializeObject(
30+
AutoSuspendActivityHelper.LatestBundle.GetString("__state"), SerializerSettings);
31+
return Observable.Return(ret);
2732
} catch (Exception ex) {
2833
return Observable.Throw<object>(ex);
2934
}

0 commit comments

Comments
 (0)