I am creating a live wallpaper in android studio. I do not want any UI besides the wallpaper, so my application contains no activities.
However, when I try to deploy to a device, I get the following error and my wallpaper will not load.
Could not identify launch activity: Default Activity not found
Error while Launching activity
How can I create an application which works that does not have a main activity?
You don't have to have the main activity in your application, or any activities at all. Check the manifest and remove the launcher-specific intent filter from your main activity if you don't want it to show up in the application list.
Therefore, unlike apps on most other systems, Android apps don't have a single entry point (there's no main() function). Because the system runs each app in a separate process with file permissions that restrict access to other apps, your app cannot directly activate a component from another app.
At the top menu in your Android Studio, select Run > Edit Configurations… menu to open the Run/Debug Configurations window. Click the OK button and run your application again. This time, the default activity launched should follow the <intent-filter> set in your AndroidManifest.
They are both instances of Context, but the application instance is tied to the lifecycle of the application, while the Activity instance is tied to the lifecycle of an Activity. Thus, they have access to different information about the application environment.
It's perfectly fine to have no activities in your application. The build succeeds, Android Studio only fails when it tries to run it, because it doesn't know what to do.
You need to modify your run configuration. Go to "Run > Edit configurations" and under "Launch options" change "Default Activity" to "Nothing":
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With