Uygulama içi yükleme istemlerini entegre etme

Bu kılavuzda, Kotlin veya Java kullanarak uygulama içi yükleme istemlerini uygulamanıza nasıl entegre edeceğiniz açıklanmaktadır.

Geliştirme ortamınızı kurma

Play uygulama içi yükleme istemleri kitaplığı, Google Play Core kitaplıklarının bir parçasıdır. Kitaplığı kullanmak için aşağıdaki Gradle bağımlılığını ekleyin:

Groovy

// In your app's build.gradle file:
...
dependencies {
    // This dependency is downloaded from the <a href="/studio/build/dependencies#google-maven">Google's Maven repository</a>.
    // So, make sure you also include that repository in your project's build.gradle file.
    implementation 'com.google.android.play:crossdeviceprompt:0.0.1-eap01'
    ...
}

Kotlin

// In your app's build.gradle.kts file:
...
dependencies {
    // This dependency is downloaded from the <a href="/studio/build/dependencies#google-maven">Google's Maven repository</a>.
    // So, make sure you also include that repository in your project's build.gradle file.
    implementation("com.google.android.play:crossdeviceprompt:0.0.1-eap01")
    ...
}

CrossDevicePromptManager'ı oluşturun

CrossDevicePromptManager, uygulamanızın bilgi istemesine ve yükleme istemi akışını başlatmasına olanak tanıyan arayüzdür. Bu kimliği almak için bir örnek oluşturun:

Kotlin

import com.google.android.play.core.crossdeviceprompt.CrossDevicePromptInfo
import com.google.android.play.core.crossdeviceprompt.CrossDevicePromptManager
import com.google.android.play.core.crossdeviceprompt.CrossDevicePromptManagerFactory
import com.google.android.play.core.crossdeviceprompt.model.CrossDevicePromptInstallationRequest

...

val crossDevicePromptManager: CrossDevicePromptManager =
    CrossDevicePromptManagerFactory.create(context)

Java

import com.google.android.play.core.crossdeviceprompt.CrossDevicePromptInfo;
import com.google.android.play.core.crossdeviceprompt.CrossDevicePromptManager;
import com.google.android.play.core.crossdeviceprompt.CrossDevicePromptManagerFactory;
import com.google.android.play.core.crossdeviceprompt.model.CrossDevicePromptInstallationRequest;

...

CrossDevicePromptManager crossDevicePromptManager =
    CrossDevicePromptManagerFactory.create(context);

CrossDevicePromptInstallationRequest nesnesi isteğinde bulunma

Uygulama akışınızda, kullanıcıya uygulamanızı başka bir cihaza yüklemesini istemek için en uygun anı belirleyin (örneğin, telefonundan TV'ye video yayınladığında). Uygulamanız bu noktalardan birine ulaştığında aşağıdaki adımları uygulayın:

  1. CrossDevicePromptInstallationRequest oluşturun.
  2. İsteği parametre olarak kabul eden bir istek görevi oluşturmak için CrossDevicePromptManager kullanın.

Görev başarılı olursa API, başarı geri çağırmasında CrossDevicePromptInfo nesnesini döndürür. Aksi takdirde, API, hata geri çağırmasında Exception döndürür.

Kotlin

val request: CrossDevicePromptInstallationRequest? =
    CrossDevicePromptInstallationRequest.create()
val result: Task<CrossDevicePromptInfo?> =
    crossDevicePromptManager.requestInstallationPromptFlow(request)

result.addOnSuccessListener { crossDevicePromptInfo ->
    // Requested a prompt flow successfully
}

result.addOnFailureListener { e ->
    // Failed to request a prompt flow
}

Java

CrossDevicePromptInstallationRequest request =
    CrossDevicePromptInstallationRequest.create();
Task<CrossDevicePromptInfo> result =
    crossDevicePromptManager.requestInstallationPromptFlow(request);

result.addOnSuccessListener(crossDevicePromptInfo -> {
    // Requested a prompt flow successfully
});

result.addOnFailureListener(e -> {
    // Failed to request a prompt flow
});

Uygulamanızı doğrulama hakkında bilgi edinmek için Uygulama içi yükleme istemlerini test etme başlıklı makaleyi inceleyin.