Start PdfActivity without PDF loaded in Kotlin for Android
See how to start a PdfActivity without any PDF document loaded. Get additional resources by visiting our guide on building an activity around the PdfFragment.
/* * Copyright © 2020-2025 PSPDFKit GmbH. All rights reserved. * * The PSPDFKit Sample applications are licensed with a modified BSD license. * Please see License for details. This notice may not be removed from this file. */
package com.pspdfkit.catalog.examples.kotlin
import android.content.Contextimport com.pspdfkit.catalog.Rimport com.pspdfkit.catalog.SdkExampleimport com.pspdfkit.configuration.activity.PdfActivityConfigurationimport com.pspdfkit.ui.PdfActivityIntentBuilder
/** * This example shows how to use [PdfActivityIntentBuilder.emptyActivity] to open the * [com.pspdfkit.ui.PdfActivity] without any document loaded. * This is most useful when also providing a custom activity subclass with options for the user to open a document. */class EmptyActivityExample(context: Context) : SdkExample(context, R.string.emptyActivityExampleTitle, R.string.emptyActivityExampleDescription) {
override fun launchExample(context: Context, configuration: PdfActivityConfiguration.Builder) { // We use emptyActivity() to start the PdfActivity without any document loaded. val intent = PdfActivityIntentBuilder.emptyActivity(context) .configuration(configuration.build()) .build() context.startActivity(intent) }}
This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.