Not able to cast the appium driver to android driver?

I am not able to cast the appium driver to android driver and getting below error.
java.lang.ClassCastException: io.appium.java_client.AppiumDriver cannot be cast to io.appium.java_client.android.AndroidDriver

Here is the sample code snippet.

driver = new AppiumDriver(new URL(“http://127.0.0.1:4723/wd/hub”), cap);

		Activity activity = new Activity(appPackageName, appActivityName);
		activity.setAppWaitPackage(appPackageName);
		activity.setAppWaitActivity(appActivityName);
		activity.setStopApp(false);
		(AndroidDriver<MobileElement>) driver.startActivity(activity);