How does this child class access the parent class within livewallpaper service.
public class LiveWallpaperService extends WallpaperService
{
public static final String SHARED_PREFS_NAME="t_settings";
public static final String strSharedPrefs="t_settings";
@Override
public Engine onCreateEngine()
{
return new LiveWallpaperWallpaperEngine();
}
public static void updatePreferences()
{
//This is the class that needs to access the child method.
Log.w("yo", "resumed from main activity");
}
public class LiveWallpaperWallpaperEngine extends Engine implements SharedPreferences.OnSharedPreferenceChangeListener
{
//This is the child method I'm trying to access.
public void updatePreferencesB(){}'
I’ve tried using Abstract which I can’t because it crashes the application also static doesn’t allow me to make any changes to objects.
The
public static void updatePreferences
Is called when the Preferences Activity is destroyed, tested and works. Now I just need a way to find out how to access the child method of the main activity feed when the onDestroy is called.
Olly.
Well, short answer is: you can’t. Part of being a
staticor class-level method means that you aren’t part of any particular instance of the class. Without providing it with some mechanism for acquiring an instance — perhaps by passing in a reference to your instance as a parameter — you’ll have to rethink how you’re doing it.