调用HP ePrint PDF预览活动时出现异常

时间:2014-03-13 06:20:51

标签: android android-intent android-activity

我正在尝试让我的Android应用程序调用HP ePrint PDF预览活动。

Intent intent = new Intent ();
intent.setPackage("com.hp.android.print");
intent.setClassName("com.hp.android.print", "com.hp.android.print.preview.PdfPreviewActivity");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.parse("http://www.pdf995.com/samples/pdf.pdf");
intent.setDataAndType( uri, "application/pdf" );

if (intent.resolveActivity(getPackageManager()) != null) 
{
     getBaseContext().startActivity(intent);
}

我收到以下错误(取自设备的Logcat):

2014-03-13 03:02:20.915 D 11119/AndroidRuntime: Shutting down VM

2014-03-13 03:02:20.915 W 11119/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40a491f8)
2014-03-13 03:02:20.925 E 11119/AndroidRuntime: FATAL EXCEPTION: main
**java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hp.android.print/com.hp.android.print.preview.PdfPreviewActivity}:** java.lang.NullPointerException
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
    at android.app.ActivityThread.access$600(ActivityThread.java:123)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4424)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)
**Caused by: java.lang.NullPointerException
    at com.hp.android.print.utils.UriUtils.normalizeIntent(UriUtils.java:133)**
    at com.hp.android.print.preview.PdfPreviewActivity.onContinueCreate(PdfPreviewActivity.java:123)
    at com.hp.android.print.preview.PrintPreview.handleExternalReceivedIntent(PrintPreview.java:261)
    at com.hp.android.print.preview.PrintPreview.onCreate(PrintPreview.java:181)
    at android.app.Activity.performCreate(Activity.java:4465)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
    ... 11 more

2014-03-13 03:02:20.935 W 132/ActivityManager:   Force finishing activity com.hp.android.print/.preview.PdfPreviewActivity
2014-03-13 03:02:20.955 W 132/ActivityManager:   Force finishing activity com.example.droidprinttest/.MainActivity

HP ePrint在手动使用时工作正常。关于修复的任何想法? [编辑]我的目标是动态打印PDF文件,没有预览的解决方案也适合我。

0 个答案:

没有答案