Android Studio Progress Bar Load PDF Multiple With Button।progress bar android example

Android Studio Progress Bar Load PDF Multiple With Button।progress bar android example


Dear friends, in this post, we will know how to add multiple buttons using Android Studio. How multiple PDFs are loaded into the activity. How to add progress bar to PDF at the same time. See details. You can also see the details in the video tutorial. So let's begin.
Rules for creating projects in Android Studio


download manager with progress bar android example


First, create a new project in Android Studio. Then by following the instructions below, it is possible to load multiple PDFs simultaneously with the PDF view and progress bar in Android Studio programming. Please follow the instructions below. 

Progress bar in android studio

In Android, ProgressBar is used to display the status of work being done like analyzing status of work or downloading a file etc. In Android, by default a progress bar will be displayed as a spinning wheel but If we want it to be displayed as a horizontal bar then we need to use style attribute as horizontal.


settings.gradle

repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://jitpack.io' }
}

build.gradle

dependencies {
    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
    implementation 'com.github.kk121:File-Loader:1.2'
}

\app\src\main\res\layout\activity_main.xml

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Button" />

<Button
    android:id="@+id/button2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Button" />

\app\src\main\java\com\example\malti\MainActivity.java

private Intent intent;
private Button button1,button2;

button2=(Button) findViewById(R.id.button2);
button1=(Button) findViewById(R.id.button1);

///// button click Start
button1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent intent=new Intent(MainActivity.this,PDF_VIEW.class);
        intent.putExtra("link","https://bd124.com/");
        startActivity(intent); }});
///////button click END

PDF View Activity

Now create a new activity to add PDF view dynamically here the button that the user will click and the button link will be given that link will automatically come here and here that PDF will be view everything is given below follow the steps.


\app\src\main\res\layout\activity_pdf_view.xml

<com.github.barteksc.pdfviewer.PDFView
    android:id="@+id/pdfView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/ProgressBar"
    android:layout_centerInParent="true"
    />

\app\src\main\java\com\example\malti\PDF_VIEW.java

private PDFView pdfView;
private String url;
private android.widget.ProgressBar ProgressBar;

pdfView = findViewById(R.id.pdfView);
    ProgressBar = findViewById(R.id.ProgressBar);
     url = url;
    Intent intent=getIntent();
    String url= getIntent().getStringExtra("url");

loadFile(url);}
private void loadFile(String url) {
    FileLoader.with(this)
            .load(url)
            .fromDirectory("assets", FileLoader.DIR_INTERNAL)
            .asFile(new FileRequestListener<File>() {
                @Override
        public void onLoad(FileLoadRequest request, FileResponse<File> response) {
                    File loadedFile = response.getBody();
                    ProgressBar.setVisibility(View.GONE);
                    // do something with the file
                    pdfView.fromFile(loadedFile)
                            .password(null)
                            .defaultPage(0)
                            .enableSwipe(true)
                            .swipeHorizontal(false)
                            .spacing(0)
                            .load();}
                @Override
                public void onError(FileLoadRequest request, Throwable t) {
       Toast.makeText(PDF_VIEW.this,"Error"+t.getMessage(), Toast.LENGTH_LONG).show();
           ProgressBar.setVisibility(View.GONE);}});


download manager with progress bar android example

how to add download button in android studio

download manager in android studio

android volley download file with progress

open downloaded file android programmatically

how to download large file in android programmatically

android download manager get progress

android download file from url using download manager

android,android studio,progress bar android studio,android studio progress bar,progress bar in android studio,how to use progress bar in android studio,android studio tutorial,progress bar android,android progress bar,progress bar,download progress bar android studio,android studio game progress bar,story progress bar android studio,custom progress bar in android studio,circular progress bar in android studio

If you have any doubts please let me know

Previous Post Next Post