Element found if user lock/unlock the device

WebElement mart_name=driver.findElement(By.xpath("//android.widget.LinearLayout[contains(@resource-id,‘inventory’)]"));
mart_name.click();

Code not working properly but if user unlock the device then code working properly.
Device don’t have any type of lock available.