I am making an app and required to execute its main functionality only by clicking on its icon.
In other words no layout no widget just its working.
As soon as user click on the icon it should execute its main functionality. One way I think of is to put all the code in onCreate
function.
Or if there is any other way please share with me.
You must have an Activity that the user launches. That activity can just call finish() by the time it returns from onResume() to not be shown (you'll also need to set android:theme="@android:style/Theme.NoDisplay"). The actual work can happen in onCreate() or such of the activity if it is very brief, otherwise you'll need to start a service which takes care of doing the work in its thread.
HOWEVER.
Having an app icon that does nothing when the user touches it is a pretty poor experience. I strongly recommend against that. You shouldn't have a main entry into your app that doesn't actually launch the app. I can assure you, doing so will result in your app rating getting lowered due to people not understanding your app. (Especially if this is actually the main activity if your app, because they will hit the "open" button in market and it will do nothing. Sucktastic.)
I don't know what you are doing, but buttons for the user to press from their home screen should generally be implemented with a widget, like the power widget. This makes it much more clear to the user what is going on, especially since visually you can make this look like a button they are pressing rather than an app they are launching.
If you just want to do some job on the background you could use a Service, this could be invoked on the onCreate method of the activity. Otherwise you could use a thread to perform your required task, and execute this thread again on the onCreate of the activity. Is that what you meant?