Merge "Fix NPE if app context is null" into pi-dev