box/box-android-preview-sdk

MP3 Preview issue on Android SDK

Closed this issue · 6 comments

Hello,

We are trying to preview mp3 file using Box SDK, The preview works fine with other files such as videos, pdf, doc, ppt, etc. However with mp3 file, it throws the following exception (although the file id is set when sending the Boxfile to the activity), the code we use to preview any file is the same:

Code:

BoxPreviewActivity.IntentBuilder builder =
BoxPreviewActivity.createIntentBuilder(getContext(), boxSharedLinkSession, boxFile);
startActivityForResult(builder.createIntent(), PREVIEW_FILE_REQUEST_CODE);

Exception:

1325-1325/com.ibm.cio.be.ppm E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ibm.cio.be.ppm, PID: 1325
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.box.androidsdk.content.models.BoxFile.getId()' on a null object reference
at com.box.androidsdk.preview.fragments.BoxPreviewMediaFragment.getMediaUri(BoxPreviewMediaFragment.java:175)
at com.box.androidsdk.preview.fragments.BoxPreviewAudioFragment.initPlayer(BoxPreviewAudioFragment.java:107)
at com.box.androidsdk.preview.fragments.BoxPreviewAudioFragment.notifyFragmentLoaded(BoxPreviewAudioFragment.java:142)
at com.box.androidsdk.preview.fragments.BoxPreviewFragment.setUserVisibleHint(BoxPreviewFragment.java:145)
at android.support.v4.app.FragmentStatePagerAdapter.setPrimaryItem(FragmentStatePagerAdapter.java:157)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1266)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:540)
at com.box.androidsdk.preview.BoxPreviewViewPager$4.run(BoxPreviewViewPager.java:206)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Hi,

Kindly find below the details you are asking for:

Preview SDK from Maven: compile 'com.box:box-android-preview-sdk:2.0.3'
buildToolsVersion: 25.0.2
Target SDK version: 25
android support:
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'

Thanks for your reply

@doncung Thank you very much for the fix. It works fine now.