How to work with already installed application using appium?
<p>Precondition: Already installed the application in device via google play.</p>

<p>When I am trying to automate the already installed application in device, than each time it open the google browser instead of opening an application.</p>

<p>Can anyone let me know how can I open the application, I an new in appium.</p>

<p>Below is the code:</p>

<pre><code>public class appium {
private static AndroidDriver driver;
    public static void main(String[] args) throws InterruptedException, IOException {

        File appDir = new File("D:/setup/android-sdk_r24.4.1-windows/android-sdk-windows");
        File app = new File(appDir, "ab.java.programming-1.apk");
        System.out.println("app Dir.---&gt;"+app);     

        DesiredCapabilities capabilities = new DesiredCapabilities();

        // Name of mobile web browser to automate. It should be an empty string, as we are automation an app
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        // Name of the OS: Android, iOS or FirefoxOS
        capabilities.setCapability("platformName", "Android");
        // Device name:  – I am using Galaxy
        capabilities.setCapability("deviceName", "Galaxy");
        // Mobile OS version –  My device is running Android 4.4.4
        capabilities.setCapability("platformVersion", "4.4.4");
        // An absolute local path to the APK file
        //capabilities.setCapability("app", app.getCanonicalPath());

        // Java package of the tested Android app
        capabilities.setCapability("appPackage", "ab.java.programming");

        // An activity name for the Android activity you want to run from your package.
        capabilities.setCapability("appActivity", ".MainActivity");

//       Constructor to initialize driver object with new Url and Capabilities
        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

        driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
        Thread.sleep(10000);
        driver.quit();

    }

    }
</code></pre>