0

내 프로젝트에서 내 확장 파일 470MB를 업로드 할 수 있으며 apk를 다운로드하는 동안 다운로드가 진행 중입니다. 확장 파일을 찾을 수없는 경우 확장 프로그램을 Play 스토어에서 다운로드하도록 앱을 안내해야합니까? 다음 링크의 지침에 따라 시도했습니다. enter link description here확장 파일을 찾을 수없는 경우 코드에서 확장 파일을 호출하는 방법은 무엇입니까?

+0

"지침에 따라 시도했지만 ...": 작동 했습니까? – Henry

답변

0

apk와 함께 확장 파일 다운로드에 사용할 수있는 샘플 코드를 따르십시오. 첫 번째 응용 프로그램 활동은 확장 파일 다운로더 활동이어야하며 확장 파일이 이미 다운로드되었는지 여부를 확인하는 한 가지 방법이 있어야합니다.

boolean expansionFilesDelivered() { 
     for (XAPKFile xf : xAPKS) { 
      String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, 
        xf.mFileVersion); 
      if (!Helpers.doesFileExist(this, fileName, xf.mFileSize, false)) 
       return false; 
     } 
     return true; 
    } 

이 메서드가 false를 반환하면 확장 파일을 다운로드해야합니다. 다음과 같이 확장 파일의 다운로드 코드를 작성해야합니다. 위의 코드 ExpansionDownloader에서

initializeDownloadUI(); 
    Intent launchIntent = ExpansionDownloader.this.getIntent(); 
        Intent intentToLaunchThisActivityFromNotification = new Intent(
          ExpansionDownloader.this, 
          ExpansionDownloader.this.getClass()); 
        intentToLaunchThisActivityFromNotification 
          .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK 
            | Intent.FLAG_ACTIVITY_CLEAR_TOP); 
        intentToLaunchThisActivityFromNotification 
          .setAction(launchIntent.getAction()); 

        if (launchIntent.getCategories() != null) { 
         for (String category : launchIntent.getCategories()) { 
          intentToLaunchThisActivityFromNotification 
            .addCategory(category); 
         } 
        } 

        // Build PendingIntent used to open this activity from 
        // Notification 
        PendingIntent pendingIntent = PendingIntent.getActivity(
          ExpansionDownloader.this, 0, 
          intentToLaunchThisActivityFromNotification, 
          PendingIntent.FLAG_UPDATE_CURRENT); 
        // Request to start the download 
        int startResult = DownloaderClientMarshaller 
          .startDownloadServiceIfRequired(this, pendingIntent, 
            ExpansionService.class); 

        if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) { 
         // The DownloaderService has started downloading the files, 
         // show progress 
         initializeDownloadUI(); 
         return; 
        } // otherwise, download not needed so we fall through to 
         // starting the movie 
       } catch (NameNotFoundException e) { 
        Log.e(LOG_TAG, "Cannot find own package! MAYDAY!"); 
        e.printStackTrace(); 
       } 

는 process.You 샘플 코드에서 ExpansionService 및 ExpansionReceiver 클래스를 얻을 수 있습니다 다운로드를 처리하는 기본 클래스입니다.