Otherwise the thread is not defined and a SecurityException may be triggered when inserting data into the ContentProvider. Sadly, below API26 this needs to be done manually. Fixes #1165.
Fixes #1164.
Fixes #896.
Part of #963.