Can anyone guide me to find a way to convert swing application to Android app.
If we just create the gui using xml is it enough to take the working code from the previous swing application to run on Android

The short answer is no. Many issues could arise by trying to "convert" the code base.
How would you test this app, which Java version are you using and so on...

Sometimes building from the ground up is the best way.

It all depends on how well your original app is structured and documented If you have designed, modularised, and layered it well then you should be able to re-use almost everythinhg except the swing GUI code (ordinary Java is pretty compatible berween SE and Android).
Go back to the design docs for the app and re-work those for Android, then see which modules have to be replaced.

If, on the other hand, it's one big heap of Java with the logic embedded in the GUI listeners then it should be scrapped anyway.

@James so can we use the login Code for Android apps which is already designed for swing application

Without seeing your code there's not a lot more I can say. IF it's modularised well then you will just need to replace the startup code (p s v main) to fit with Android, and replace the Swing GUI elements. If it's not well modularised then you'll have to re-write it.

If(unname="Raj" and password ="man")
Success
Else
No
Can we use this same code in both swings and Android

@James see the above code and tell me sir

That's not Java code, so you can't use it on either.
How big (number of lines) is you application today?

150 lines to 200

OK. In that case just re-write it. It's far too small to have much in the way of reusable parts.

If the working code is in 15 lines can we use???

If it's not code for the startup or for the GUI then probably yes.
This is such a tiny program you should just get on and do it without any more worrying. If you get stuck people here will help.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.