![]() And set the URI to our pdfviewer object in the MainActivity.java class's onCreate() method. Get the intent and know whether it is a send or a view intent before accessing the URI. Include the READ_EXTERNAL_STORAGE permission in the manifest file. Log.d("PERMISSION", "Already has permission to write to external storage") We were granted permission already before ![]() Log.d("PERMISSION", "After getting permission: " + _EXTERNAL_STORAGE + " " + ContextCompat.checkSelfPermission(Ī_EXTERNAL_STORAGE)) if (ContextCompat.checkSelfPermission(Ī_EXTERNAL_STORAGE) =Ī_EXTERNAL_STORAGE Now take the READ_EXTERNAL_STORAGE permission from the user in the onCreate() method in MainActivity.java class. private final int EXT_STORAGE_PERMISSION_CODE = 1 ![]() ![]() ĭeclare PDFView objects and declare the variable EXT_STORAGE_PERMISSION_CODE to take permission from the user for READ_EXTERNAL_STORAGE in the MainActivity.java class. t(RepositoriesMode.FAIL_ON_PROJECT_REPOS)Ĭreate the activity_main.xml file as shown below. it is based on which Android Studio you used sometimes, we add jcenter() in adle Project level file. After that, your adle file looks like the following. implementation ':android-pdf-viewer:2.8.2'Īnd if jcenter is unavailable in your adle file, add jcenter(). Give the project a name, select the save location folder, and click the finish button.Īdd the following dependency in the adle app level file. Create a PDF Viewer App that handles VIEW And SEND Intent FilterĬreate a new project in the Android Studio and select an empty activity. ![]() Therefore, when someone taps on the logo of your app, a pdf file opens in it. We will also include a SEND intent filter in this app, allowing it to appear on a list whenever a PDF file is shared. This functionality is supported due to the VIEW intent filter. When you click on a pdf file, it displays a list of applications that can handle pdf files therefore, after you install your app, it will appear in the list if a user clicks on your app's logo and views a pdf file displayed in your app. Here, we create an app that can open a PDF file. In this article, we will learn how to make your PDF viewer handle PDF files with intent filters in Android. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |