APK拡張ファイルをダウンロードするこのコードがあります
private void performAPKExpansionCheckAndDownload(){
String APK_LOG = "APK_LOG";
String mainFileName = Helpers.getExpansionAPKFileName(this, true, 2);
Log.d(APK_LOG,"mainFileName "+mainFileName);
boolean fileExists = Helpers.doesFileExist(this, mainFileName, 38783430L, false);
Log.d(APK_LOG,"fileExists "+fileExists);
if (!fileExists) {
Intent launcher = getIntent();
Intent fromNotification = new Intent(this, getClass());
fromNotification.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
fromNotification.setAction(launcher.getAction());
if (launcher.getCategories() != null) {
for (String cat : launcher.getCategories()) {
Log.d(APK_LOG,"cat "+cat);
fromNotification.addCategory(cat);
}
}
PendingIntent pendingIntent = PendingIntent.getActivity(
this, 0, fromNotification, PendingIntent.FLAG_UPDATE_CURRENT);
try {
int result = DownloaderClientMarshaller.startDownloadServiceIfRequired(
this, pendingIntent, MyDownloaderService.class);
Log.d(APK_LOG,"result "+result);
if (DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED != result) {
// implement Downloading UI.
return;
}
} catch (NameNotFoundException e) {
Log.e("apk-expansion-files", "NameNotFoundException occurred. " + e.getMessage(), e);
}
}
}
問題は、onDownloadFinishedやonProgressUpdateなどのコールバックを処理する必要があることです。たくさんのメッセージがどこかに投稿されていることは知っていますが、それらを処理する方法がわかりません。私はAndroidでメッセージを操作したことがないので、何か助けていただければ幸いです。
アップデート:
すべてのダウンロードはここで行われます:
int result = DownloaderClientMarshaller.startDownloadServiceIfRequired(
this, pendingIntent, MyDownloaderService.class);
if (DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED != result) {
// implement Downloading UI.
return;
}
これらのコールバックは、そのDownloaderClientMarshallerクラスに接続する必要があると思います。