I have downloaded some Office files(doc, xls, pdf etc) on SDcard from FTP server and now I want to view those files using third party application.
I am using below code for Intent (in this case a PDF File):
PackageManager packageManager = getPackageManager();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("application/pdf");
List list = packageManager.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0)
{
Uri uri_path = Uri.parse(path);
intent.setDataAndType(uri_path, "application/pdf");
try
{
startActivity(intent);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(getApplicationContext(),"No Application Available to View PDF", Toast.LENGTH_SHORT).show();
}
}
But when I try to open the file a White Screen appears and disappears. And in DDMS I get the following:
01-14 16:14:17.900: ERROR/Quickoffice(1204): java.lang.NullPointerException
01-14 16:14:17.900: ERROR/Quickoffice(1204): at s.a(Unknown Source)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at com.qo.android.quickcommon.OfficeActivity.a(Unknown Source)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at com.qo.android.quickcommon.OfficeActivity.a(Unknown Source)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at com.qo.android.quickword.Quickword.onCreate(Unknown Source)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at android.os.Handler.dispatchMessage(Handler.java:99)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at android.os.Looper.loop(Looper.java:132)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at android.app.ActivityThread.main(ActivityThread.java:4028)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at java.lang.reflect.Method.invokeNative(Native Method)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at java.lang.reflect.Method.invoke(Method.java:491)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
01-14 16:14:17.900: ERROR/Quickoffice(1204): at dalvik.system.NativeStart.main(Native Method)
Please help me on this issue. I don’t understand the problem. When I goto SDCard using “ES File Explorer” and opens the file, it gets opened. All the files(doc xls and PDF) gets opened correctly.
Got my answer. I needed to add the following for my URI: