我是android新手…尝试从动态壁纸打开URL时遇到麻烦.
打开URL的代码:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
Activity activity = new Activity();
activity.startActivity(intent);
但是我只是得到一个NullpointerException:
java.lang.NullPointerException
at android.app.Activity.startActivityForResult(Activity.java:2749)
at android.app.Activity.startActivity(Activity.java:2855)
at org.amble.graphics.HToolbar$URLEntry.run(HToolbar.java:81)
at org.amble.graphics.HToolbar.doTouch(HToolbar.java:188)
at com.mobstar.undeadpirate.autopaper.PiratePaperPainter.doTouchEvent(PiratePaperPainter.java:245)
at com.mobstar.undeadpirate.autopaper.LiveWallpaperService$WallpaperEngine.onTouchEvent(LiveWallpaperService.java:117)
at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:832)
at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:45)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
我的清单看起来像这样
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="com.nubjub.wallpapertest">
android:label="@string/app_name" android:debuggable="true" android:icon="@drawable/icon">
android:name="WallpaperTest"
android:enabled="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:permission="android.permission.BIND_WALLPAPER">
android:name="android.service.wallpaper"
android:resource="@xml/wallpaper" />