As you know, when app is nomally installed, icon is created at launcher menu screen. What I want to do is create icon at user home screen during installation. (without press
I had trouble with the above answers and that's because API 22 and maybe other APIs returns on getApplicationInfo().className in debug/emulation mode:
"com.android.tools.fd.runtime.BootstrapApplication"
Most important thing is that I needed to set the entire path to the class for the class name. (see the changes)
For example, I had the following:
packageName=com.example.user.myapp
className=MainActivity
In Kailash answer I needed to change this line:
shortcutIntent.setClassName("packageName", "className");
to
shortcutIntent.setClassName("com.example.user.myapp", "com.example.user.myapp.MainActivity");
In ChristopheCVBs answer I needed to change this line:
ComponentName comp = new ComponentName(appInfo.packageName, appInfo.className);
to
ComponentName comp = new ComponentName(appInfo.packageName, appInfo.packageName+".MainActivity");