Back button "click" by application

Probably someone has asked this earlier but couldnt find proper answer from community so here we go:
is there a way to "click" back button by application?
Question is related to my small barcode scanner -project. If barcode scanner cant read the code within timeout then I could call "back button clicked" and app would exit from scanning screen (just like it does when physical back button is pressed)

just call the function (like close screen) when time out.

Thanks for suggestion but it didnt work. Only clicking physical back -button takes me out from scanning screen or when scanning gets result


Sorry, I misunderstand your meaning. You want to quit the scanning, which I have no idea.