3

I'm trying to start default android wallpaper chooser. I'm using:

Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
    startActivity(intent);

This code works but it opens app chooser. I want to open "Wallpapers" directly. My minSdkVersion is set to 16.

movil
  • 33
  • 4

1 Answers1

0

By "default" you seem to mean the wallpaper app that came with Android OS, rather than other wallpaper apps that the device may have. You can force Android to launch a particular activity by setting the component in the intent.

Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
intent.setComponent(...);
startActivity(intent);

However, this is a risky thing to do. If you run this code on a device that doesn't have the wallpaper app that you've specified, then you will get an ActivityNotFoundException.

Do you really need to launch one particular wallpaper app? A central feature of Android is that you say what you want to do, and it finds the app to do it. I don't know what your goal is, but another function that might be helpful is PackageManager.resolveActivity. You can use it to discover, in code, what app would be launched for a particular intent.

http://developer.android.com/reference/android/content/pm/PackageManager.html

Hope this helps.

Bruce
  • 2,377
  • 1
  • 17
  • 11