How to change activity in appium android

I am using appium to automate native app. For the application launcher activity name is HomeActivity and it works fine if user logged in and redirect to home screen .

if user not logged in it redirects to welcome screen. In this case i am using HomeActivity to launch the app even app launches successfully with error as
“A new session could not be created. (Original error: never started. Current: (WARNING: The server did not provide any stacktrace information)”

Please help!!!. Please provide code to change activity.

Fror me it’s not about code, it’s about test cases…
You have two scenarios: one with the fresh/first install and another with app in use.

For fresh/first install call you script with APP capability.
For the app in use set the activity capability.