Am using xiomi note4 device to perform the below test to open google and type "Hello Appium".
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class Webapp {
public static AndroidDriver<WebElement> driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
// TODO Auto-generated method stub
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.BROWSER_NAME, "Chrome");
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Xiomi");
cap.setCapability("unlockType", "pattern");
cap.setCapability("unlockKey","2583");
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),cap);
driver.get("http://google.com");
driver.manage().timeouts().implicitlyWait(10l, TimeUnit.SECONDS);
driver.findElement(By.name("q")).sendKeys("hello Appium");
Thread.sleep(3000);
driver.quit();
}
}