单独的动态壁纸的多种设置
我有两个属于同一应用程序的动态壁纸,我试图为每个动态壁纸设置单独的首选项设置,但我遇到了两个壁纸都使用第一个设置的问题。
<application android:icon="@drawable/icon" android:label="@string/app_name">
<service
android:label="first wallpaper"
android:name="com.package.this1.number1"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper" android:resource="@xml/source1" />
</service>
<service
android:label="second wallpaper"
android:name="com.package.this2.number2"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper" android:resource="@xml/source2" />
</service>
<activity android:label="@string/settings"
android:name=".this1.Settings1"
android:exported="true"
android:icon="@drawable/icon">
</activity>
<activity android:label="@string/settings"
android:name=".this2.Settings2"
android:exported="true"
android:icon="@drawable/icon">
</activity>
</application>
我是否错过了一些简单的事情,或者如果不制作两个单独的应用程序就无法做到这一点?
这是我的 Settings1 和 Settings2 类的代码
public class Settings1 extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
getPreferenceManager().setSharedPreferencesName(number1.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.this1_settings);
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
public class Settings2 extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
getPreferenceManager().setSharedPreferencesName(number2.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.this2_settings);
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
任何建议将不胜感激。
I have two Live Wallpapers that belong to the same Application and I am trying to have separate Preference settings for each one but I have run into the issue of the first settings being used by both Wallpapers.
<application android:icon="@drawable/icon" android:label="@string/app_name">
<service
android:label="first wallpaper"
android:name="com.package.this1.number1"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper" android:resource="@xml/source1" />
</service>
<service
android:label="second wallpaper"
android:name="com.package.this2.number2"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper" android:resource="@xml/source2" />
</service>
<activity android:label="@string/settings"
android:name=".this1.Settings1"
android:exported="true"
android:icon="@drawable/icon">
</activity>
<activity android:label="@string/settings"
android:name=".this2.Settings2"
android:exported="true"
android:icon="@drawable/icon">
</activity>
</application>
Am I missing something simple or is it not possible to do this without making 2 separate applications?
Here's the code of my Settings1 and Settings2 classes
public class Settings1 extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
getPreferenceManager().setSharedPreferencesName(number1.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.this1_settings);
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
public class Settings2 extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
getPreferenceManager().setSharedPreferencesName(number2.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.this2_settings);
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
Any advice would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Moonblink(Android Tricorder 的创建者)也有一系列名为 Substrate 的动态壁纸。 Substrate 确实将多个壁纸组合到一个包中,并且多个壁纸具有设置活动。我建议你检查一下他的结构。从这里开始 http://code.google.com/p/moonblink/source/browse/
并寻找基板(在行李箱下)。希望这有帮助。
PS 项目主页位于:http://code.google.com/p/moonblink/维基/Substrate
Moonblink (creator of Android Tricorder) also has a collection of live wallpapers called Substrate. Substrate does indeed combine multiple wallpapers into a single package, and more than one of the wallpapers has a settings activity. I suggest you examine his structure. Start here http://code.google.com/p/moonblink/source/browse/
and look for Substrate (under trunk). Hope this helps.
P.S. The project home is here: http://code.google.com/p/moonblink/wiki/Substrate