I am invalidating and re-creating the snapshot each time the app is resumed.
It works when I switch between apps, when I lock and unlock the phone using a pattern or face recognition. Although if I lock my device while I’m on the app and unlock my phone using my fingerprint, the snapshot disappears.
Any idea what could be the reason?
Also, if I have locked and unlocked the phone with either face recognition or pattern, and then lock and unlock with fingerprint, it works sometimes!
Here’s the code:
local SnapshotObject = require(...');
local M = {};
function M.new(params)
local instance = display.newGroup();
local obj1;
local function render()
obj1 = SnapshotObject .new(params);
end
render();
local onSystemEvent = function(event)
if (event.type == 'applicationResume') then
if (instance and instance.insert) then
obj1:removeSelf();
render();
instance:insert(obj1);
else
instance = nil;
Runtime:removeEventListener("system", onSystemEvent);
return;
end
end
end
Runtime:addEventListener("system", onSystemEvent);
instance:insert(obj1);
return instance;
end
return M;