I am currently working on a Live Wallpaper in Android.
It turned out the Samsung's TouchWiz launcher never calls the onOffsetChanged
method. The only way here is to detect if TouchWiz is running and to simulate the scrolling accordingly.
Is there a way to detect if my Live Wallpaper is running under Samsung's TouchWiz launcher?

- 171
- 8

- 7,896
- 13
- 62
- 94
-
Relevant question: http://stackoverflow.com/questions/8626421/get-preferred-default-app-on-android - Just replace the browser intent with the home intent. – Machinarius Nov 14 '14 at 14:03
2 Answers
You can detect if a Launcher is Installed using the following code provided in the examples below;
First One
boolean isLauncherInstalled () {
final String myLauncherPackageName = "LAUNCHER PACKAGE NAME"; // com.sec.android.app.launcher
final IntentFilter filterCategory = new IntentFilter(Intent.ACTION_MAIN);
filter.addCategory(Intent.CATEGORY_HOME);
List<IntentFilter> filters = new ArrayList<IntentFilter>();
filters.add(filterCategory);
List<ComponentName> activities = new ArrayList<ComponentName>();
final PackageManager packageManager = (PackageManager) getPackageManager();
packageManager.getPreferredActivities(filters, activities, null);
for (ComponentName activity : activities) {
if (myLauncherPackageName.equals(activity.getPackageName())) {
return true; // Is a match so you have a Launcher installed.
}
}
return false; // No Launcher.
}
Second One
public boolean isLauncherInstalled() {
final String myLauncherPackageName = "LAUNCHER PACKAGE NAME"; // com.sec.android.app.launcher
IntentFilter filterCategory = new IntentFilter(Intent.ACTION_MAIN);
filterCategory.addCategory(Intent.CATEGORY_HOME);
List<IntentFilter> filters = new ArrayList<IntentFilter>();
filters.add(filterCategory);
List<ComponentName> preferredActivities = new ArrayList<ComponentName>();
final PackageManager packageManager = (PackageManager) getPackageManager();
packageManager.getPreferredActivities(filters, preferredActivities, myLauncherPackageName);
if (preferredActivities != null && preferredActivities.size()> 0) {
return true; // Is a match so you have a Launcher installed.
}
return false; // No Launcher.
}
However your best option wil be to always simulate scrolling, because there are more Launchers that don't trigger OnOffsetsChanged
. But when you actually get a call to OnOffsetsChanged
just disable simulated scrolling. This way OnOffsetsChanged
can function normally if it's available.
The following article will give you an idea of how to approach this; Artikel Link

- 171
- 8
-
Won't this trigger even if TouchWiz is not in use? Like, say I'm using Nova, but TouchWiz is still installed. – Josh Nov 14 '14 at 20:00
Don't try to detect the launcher, as HTC does this on some devices as well.
Better solution is to assume you WON'T get scroll events, and ALWAYS initially do your simulated scrolling. Then, if you get a call to onOffsetChanged
(which will happen with most launchers), disable your simulated scrolling and carry on as normal.

- 10,618
- 2
- 32
- 36