启动器,必须具有android.permission.SET_WALLPAPER_HINTS权限

时间:2012-11-16 03:34:01

标签: android

我在运行qpp时遇到了一些错误,我不知道如何解决这个问题,有人会帮我吗?我在虚拟机上运行我的应用程序,并且我已经添加了权限

11-14 10:09:06.565: E/AndroidRuntime(402): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hskj.iphonehome/com.hskj.iphonehome.Launcher}: java.lang.SecurityException: Access denied to process: 402, must have permission android.permission.SETWALLPAPERHINTS
11-14 10:09:06.565: E/AndroidRuntime(402): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1735)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1754)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.app.ActivityThread.access$1500(ActivityThread.java:156)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1000)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.os.Handler.dispatchMessage(Handler.java:130)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.os.Looper.loop(SourceFile:351)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.app.ActivityThread.main(ActivityThread.java:3821)
11-14 10:09:06.565: E/AndroidRuntime(402): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 10:09:06.565: E/AndroidRuntime(402): at java.lang.reflect.Method.invoke(Method.java:538)
11-14 10:09:06.565: E/AndroidRuntime(402): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
11-14 10:09:06.565: E/AndroidRuntime(402): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
11-14 10:09:06.565: E/AndroidRuntime(402): at dalvik.system.NativeStart.main(Native Method)
11-14 10:09:06.565: E/AndroidRuntime(402): Caused by: java.lang.SecurityException: Access denied to process: 402, must have permission android.permission.SETWALLPAPERHINTS
11-14 10:09:06.565: E/AndroidRuntime(402): at android.os.Parcel.readException(Parcel.java:1353)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.os.Parcel.readException(Parcel.java:1307)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.app.IWallpaperManager$Stub$Proxy.setDimensionHints(IWallpaperManager.java:343)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.app.WallpaperManager.suggestDesiredDimensions(WallpaperManager.java:717)
11-14 10:09:06.565: E/AndroidRuntime(402): at com.hskj.iphonehome.Launcher.setWallpaperDimension(Launcher.java:482)
11-14 10:09:06.565: E/AndroidRuntime(402): at com.hskj.iphonehome.Launcher.onCreate(Launcher.java:322)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082)
11-14 10:09:06.565: E/AndroidRuntime(402): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1699)
11-14 10:09:06.565: E/AndroidRuntime(402): ... 11 more

修改

这是关键代码:

private static final int WALLPAPERSCREENSSPAN = 1;
WallpaperManager wpm = (WallpaperManager) getSystemService(WALLPAPER_SERVICE);
    Display display = getWindowManager().getDefaultDisplay();

    final int width = display.getWidth();
    final int height = display.getHeight();

    wpm.suggestDesiredDimensions(width * WALLPAPER_SCREENS_SPAN, height);

EDIT2:

我已在我的应用中添加了权限:

<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS"/>

但错误仍然相同。我想知道它是否是由模拟器引起的,但我不确定。有人可以帮我吗?这个问题让我非常困扰。

感谢您对我的问题的全部关注,我已经解决了问题,模拟器中出现了问题,我将其全部重置,所以它就解决了。

2 个答案:

答案 0 :(得分:2)

根据你的stacktrace

java.lang.SecurityException: Access denied to process: 402, must have permission android.permission.SETWALLPAPERHINTS

您应该在清单中添加权限。这是

<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS"/>

答案 1 :(得分:1)

您需要向清单添加SET_WALLPAPER_HINTS权限:

<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS"/>