How to write script for app in successfully installed or not in device?

Hi,
In configuration installed the .apk file.
like
File app = new File(“E:\apk\TOG\TOG_Community_2.0.1.apk”);
DesiredCapabilities capabilities= new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, “”);
capabilities.setCapability(“deviceName”,“02232934307b86fc”);
capabilities.setCapability(“platformversion6.0.1”, “”);
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“package”, “com.tog.togcommunity”);
capabilities.setCapability(“Activity”, “com.tog.togcommunity.SplashActivity”);
capabilities.setCapability(“app”, app.getAbsolutePath());
driver= new AndroidDriver<>( new URL(“http://127.0.0.1:4723/wd/hub”), capabilities) ;

So after how i can check the app is successfully installed or not?

.
if()
{
System.out.println(“TOG app is installed successfully”);
}
else
System.out.println(“TOG app is Not installed successfully”);

App name: TOG

driver.isAppInstalled(“package_of_your_app”)

Hi can you please explain clearly,
File app = new File(“E:\apk\TOG\TOG_Community_2.0.1.apk”);
DesiredCapabilities capabilities= new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, “”);
capabilities.setCapability(“deviceName”,“02232934307b86fc”);
capabilities.setCapability(“platformversion6.0.1”, “”);
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“package”, “com.tog.togcommunity”);
capabilities.setCapability(“Activity”, “com.tog.togcommunity.SplashActivity”);
capabilities.setCapability(“app”, app.getAbsolutePath());
driver= new AndroidDriver<>( new URL(“http://127.0.0.1:4723/wd/hub”), capabilities) ;

if(driver.isAppInstalled(“com.tog.togcommunity”))
{
System.out.println(“TOG app is installed successfully”);
driver.findElement(by.name(“TOG Community”)).click();
}
else
System.out.println(“TOG app is Not installed successfully”);

yes, your code should work (when you add { } to ELSE statement ). In additional, not all you capabilities are required, just “deviceName”, “appPackage”, “appActivity”. It’s enough to start appium session.

Hi ,I want to check whether app is installed or not in device if it does not present into device then it should install app. I am stuck in it. Please share code snippet. Thank you in advance…