@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
WallpaperManager myWallpaperManager = WallpaperManager
.getInstance(getApplicationContext());
try {
myWallpaperManager.setResource(R.id.full_image_view);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
logcat的:
12-12 00:39:20.240: I/dalvikvm(687): Could not find method com.google.inject.Injector.getInstance, referenced from method de.dan_nrw.android.scroid.DependencyInjector.getInstance
12-12 00:39:20.310: W/dalvikvm(687): VFY: unable to resolve interface method 3344: Lcom/google/inject/Injector;.getInstance (Ljava/lang/Class;)Ljava/lang/Object;
12-12 00:39:20.310: D/dalvikvm(687): VFY: replacing opcode 0x72 at 0x000e
12-12 00:39:20.320: E/dalvikvm(687): Could not find class 'com.google.inject.Module[]', referenced from method de.dan_nrw.android.scroid.DependencyInjector.init
12-12 00:39:20.370: W/dalvikvm(687): VFY: unable to resolve new-array 684 ([Lcom/google/inject/Module;) in Lde/dan_nrw/android/scroid/DependencyInjector;
12-12 00:39:20.370: D/dalvikvm(687): VFY: replacing opcode 0x23 at 0x0001
12-12 00:39:20.413: W/dalvikvm(687): Unable to resolve superclass of Lde/dan_nrw/android/scroid/ProductiveModule; (472)
12-12 00:39:20.450: W/dalvikvm(687): Link of class 'Lde/dan_nrw/android/scroid/ProductiveModule;' failed
12-12 00:39:20.450: D/dalvikvm(687): DexOpt: unable to opt direct call 0x0d30 at 0x06 in Lde/dan_nrw/android/scroid/DependencyInjector;.init
12-12 00:39:20.471: D/AndroidRuntime(687): Shutting down VM
12-12 00:39:20.471: W/dalvikvm(687): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-12 00:39:20.511: E/AndroidRuntime(687): FATAL EXCEPTION: main
12-12 00:39:20.511: E/AndroidRuntime(687): java.lang.NoClassDefFoundError: com.google.inject.Module[]
12-12 00:39:20.511: E/AndroidRuntime(687): at de.dan_nrw.android.scroid.DependencyInjector.init(DependencyInjector.java:37)
12-12 00:39:20.511: E/AndroidRuntime(687): at de.dan_nrw.android.scroid.ScroidWallpaperGallery.<init>(ScroidWallpaperGallery.java:84)
12-12 00:39:20.511: E/AndroidRuntime(687): at java.lang.Class.newInstanceImpl(Native Method)
12-12 00:39:20.511: E/AndroidRuntime(687): at java.lang.Class.newInstance(Class.java:1319)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.os.Looper.loop(Looper.java:137)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-12 00:39:20.511: E/AndroidRuntime(687): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 00:39:20.511: E/AndroidRuntime(687): at java.lang.reflect.Method.invoke(Method.java:511)
12-12 00:39:20.511: E/AndroidRuntime(687): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-12 00:39:20.511: E/AndroidRuntime(687): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-12 00:39:20.511: E/AndroidRuntime(687): at dalvik.system.NativeStart.main(Native Method)
12-12 00:39:23.931: I/Process(687): Sending signal. PID: 687 SIG: 9
12-12 00:44:23.441: I/dalvikvm(728): Could not find method com.google.inject.Injector.getInstance, referenced from method de.dan_nrw.android.scroid.DependencyInjector.getInstance
12-12 00:44:23.491: W/dalvikvm(728): VFY: unable to resolve interface method 3344: Lcom/google/inject/Injector;.getInstance (Ljava/lang/Class;)Ljava/lang/Object;
12-12 00:44:23.491: D/dalvikvm(728): VFY: replacing opcode 0x72 at 0x000e
12-12 00:44:23.491: E/dalvikvm(728): Could not find class 'com.google.inject.Module[]', referenced from method de.dan_nrw.android.scroid.DependencyInjector.init
12-12 00:44:23.491: W/dalvikvm(728): VFY: unable to resolve new-array 684 ([Lcom/google/inject/Module;) in Lde/dan_nrw/android/scroid/DependencyInjector;
12-12 00:44:23.491: D/dalvikvm(728): VFY: replacing opcode 0x23 at 0x0001
12-12 00:44:23.511: W/dalvikvm(728): Unable to resolve superclass of Lde/dan_nrw/android/scroid/ProductiveModule; (472)
12-12 00:44:23.521: W/dalvikvm(728): Link of class 'Lde/dan_nrw/android/scroid/ProductiveModule;' failed
12-12 00:44:23.551: D/dalvikvm(728): DexOpt: unable to opt direct call 0x0d30 at 0x06 in Lde/dan_nrw/android/scroid/DependencyInjector;.init
12-12 00:44:23.551: D/AndroidRuntime(728): Shutting down VM
12-12 00:44:23.561: W/dalvikvm(728): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-12 00:44:23.641: E/AndroidRuntime(728): FATAL EXCEPTION: main
12-12 00:44:23.641: E/AndroidRuntime(728): java.lang.NoClassDefFoundError: com.google.inject.Module[]
12-12 00:44:23.641: E/AndroidRuntime(728): at de.dan_nrw.android.scroid.DependencyInjector.init(DependencyInjector.java:37)
12-12 00:44:23.641: E/AndroidRuntime(728): at de.dan_nrw.android.scroid.ScroidWallpaperGallery.<init>(ScroidWallpaperGallery.java:84)
12-12 00:44:23.641: E/AndroidRuntime(728): at java.lang.Class.newInstanceImpl(Native Method)
12-12 00:44:23.641: E/AndroidRuntime(728): at java.lang.Class.newInstance(Class.java:1319)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.os.Looper.loop(Looper.java:137)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-12 00:44:23.641: E/AndroidRuntime(728): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 00:44:23.641: E/AndroidRuntime(728): at java.lang.reflect.Method.invoke(Method.java:511)
12-12 00:44:23.641: E/AndroidRuntime(728): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-12 00:44:23.641: E/AndroidRuntime(728): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-12 00:44:23.641: E/AndroidRuntime(728): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:1)
你没有给我们太多的帮助,但这是不正确的:
myWallpaperManager.setResource(R.id.full_image_view);
您需要从res/drawable
个文件夹之一传递资源:
myWallpaperManager.setResource(R.drawable.my_wallpaper);