Open zohaib319 opened 5 years ago
Hello,
thanks for the detailed info and the code sample. Finding the cause with this information is much easier.
Note that you are closing the adapter in onDestroy()
and only assigning it in the onSuccess
case, so if you close the activity without reaching onSuccess
, you might get a NPE. But this doesn't seem to be your case because you are getting a RuntimeException.
I'll try to reproduce my code samples in one of the mentioned phones to see if I also get the crash in Oreo
Hi Thanks for the quick reply by the way. I have this scenario working. I have a different Activity for PDF View. Adapter should be created when i navigate to that activity. some times on fresh install I am getting NPE before even navigating to the PDF Activity. This issue is very much concerning right now.
And by the way i have also tried creating the new pdfpageradapter in my Custom Dialogue and this way it didn't work but prevent the crashes.
Crash Report java.lang.RuntimeException: at android.app.ActivityThread.performDestroyActivity (ActivityThread.java:5046) at android.app.ActivityThread.handleDestroyActivity (ActivityThread.java:5065) at android.app.ActivityThread.-wrap6 (Unknown Source) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1955) at android.os.Handler.dispatchMessage (Handler.java:108) at android.os.Looper.loop (Looper.java:166) at android.app.ActivityThread.main (ActivityThread.java:7425) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921) Caused by: java.lang.NullPointerException: at com.govpk.citizensportal.PdfManual.onDestroy (PdfManual.java:169) at android.app.Activity.performDestroy (Activity.java:7604) at android.app.Instrumentation.callActivityOnDestroy (Instrumentation.java:1253) at android.app.ActivityThread.performDestroyActivity (ActivityThread.java:5033)
Devices which are observing crash issues.
Java code Pasted Below . import android.Manifest; import android.app.Dialog; import android.content.Context; import android.content.pm.PackageManager; import android.os.Build; import android.os.Environment; import android.os.Handler; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.ViewStub; import android.view.Window; import android.webkit.WebView; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.Toast;
import com.govpk.views.FontTextView; import com.govpk.views.InfoDialogFragment; import com.gun0912.tedpermission.PermissionListener; import com.gun0912.tedpermission.TedPermission; import java.util.ArrayList; import butterknife.BindView; import butterknife.ButterKnife; import es.voghdev.pdfviewpager.library.RemotePDFViewPager; import es.voghdev.pdfviewpager.library.adapter.PDFPagerAdapter; import es.voghdev.pdfviewpager.library.remote.DownloadFile; import es.voghdev.pdfviewpager.library.util.FileUtil;
public class PdfManual extends AppCompatActivity implements DownloadFile.Listener { public static String url; @BindView(R.id.remote_pdf) RemotePDFViewPager remotePdf; public PDFPagerAdapter pdfPagerAdapter; @BindView(R.id.root_layout) RelativeLayout rootLayout; @BindView(R.id.layout_progress) LinearLayout layoutProgress; @BindView(R.id.layout_error) LinearLayout layoutError;
// setToolbar(true, false, "Citizen Manual"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { TedPermission.with(PdfManual.this) .setPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE) .setDeniedMessage("If you reject permission, You will not be able to see the Manual") .setPermissionListener(new PermissionListener() { @Override public void onPermissionGranted() { showSelectionDialogue(PdfManual.this); } @Override public void onPermissionDenied(ArrayList deniedPermissions) {
InfoDialogFragment infoDialogFragment = InfoDialogFragment.newInstance("Permission", "Enable storage permission");
infoDialogFragment.setOnInfoClickListener(new InfoDialogFragment.InfoDialogListener() {
@Override
public void onInfoDialogOkClick() {
}
Anything needed I will be more then happy to provide. please resolve this issue.