Frage

I am trying to use the Samsung Multiwindow-SDK function within my application to open a PDF in Polaris office.

I have the following code:

if (file.exists()) {
                        try{
                            Uri path2 = Uri.fromFile(file);
                            Intent i = new Intent(Intent.ACTION_VIEW);
                            i.setDataAndType(path2, "application/pdf");
                    PackageManager manager = getPackageManager();
                    i = manager.getLaunchIntentForPackage("com.infraware.PolarisOfficeStdForTablet");
                    i.putExtras(mMWM.makeMultiWindowAppIntent(SMultiWindowManager.FREE_AND_PINUP_STYLE, new Rect(640, 0, 1280, 752)));
                    i.addCategory(Intent.CATEGORY_LAUNCHER);
                    startActivity(i);

                    } 
                    catch (ActivityNotFoundException e) {

                    }

The polaris window is opening in multiwindow mode but the pdf file I am sending across isnt opening.

Can someone help me understand why the PDF isnt opening and how I can modify my code to get it working?

Thanks;

Andy

War es hilfreich?

Lösung

The following worked for me in the end. Answered in case anyone finds this thread with a similar problem in future.

  private void openPdfInPolarisOffice(File myPdfFile) {
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Rect rect = new Rect(640, 0, 1280, 752);
        Intent e = mMWM.makeMultiWindowAppIntent(SMultiWindowManager.SPLIT_ZONE_B, null);
        i.putExtras(e);            
        i.setDataAndType(Uri.fromFile(myPdfFile), "application/pdf");
        startActivity(i);
    }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top