2017-03-20 9 views
0

起動時にアプリケーションに拡張ファイルをダウンロードさせようとしています。私はguide from Androidに続き、しばらくの間はダウンロードを開始し、98%で停止してファイルを確認できなかったが、ファイルは実際にそこにあった。今日、私はコードを変更していないし、ダウンロードしようとしていない。私はクラス全体にブレークポイントを入れて、それはIDownloaderClientから来るonServiceConnectedメソッドには決して行きません。 のonCreateの終わりに IDownloaderClient onServiceConnected呼び出されていない

私が持っている

initializeDownloadUI(); 

if (!expansionFilesDelivered()) { 
    try { 
     final Intent launchIntent = MainActivity.this.getIntent(); 
     final Intent intentToLaunchThisActivityFromNotification = new Intent(MainActivity.this, MainActivity.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. 
     final PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 0, intentToLaunchThisActivityFromNotification, PendingIntent.FLAG_UPDATE_CURRENT); 

     // Request to start the download. 
     final int startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(this, pendingIntent, DownloaderServiceHelper.class); 

     if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) { 
      initializeDownloadUI(); 
      return; 
     } 
    } catch (PackageManager.NameNotFoundException exc) { 
     Log.wtf("MainActivity", "Cannot find own package."); 
     exc.printStackTrace(); 
    } 
} else validateXAPKZipFiles(); 

そして、私のinitializeDownloadUI()は私onResume

if (null != mDownloaderClientStub) { 
    mDownloaderClientStub.connect(this); 
} 

super.onResume(); 
あり、また

mDownloaderClientStub = DownloaderClientMarshaller.CreateStub(this, DownloaderService.class); 
setContentView(R.layout.main); 

mPB = (ProgressBar) findViewById(R.id.progressBar); 
mStatusText = (TextView) findViewById(R.id.statusText); 
mProgressFraction = (TextView) findViewById(R.id.progressAsFraction); 
mProgressPercent = (TextView) findViewById(R.id.progressAsPercentage); 
mAverageSpeed = (TextView) findViewById(R.id.progressAverageSpeed); 
mTimeRemaining = (TextView) findViewById(R.id.progressTimeRemaining); 
mDashboard = findViewById(R.id.downloaderDashboard); 
mCellMessage = findViewById(R.id.approveCellular); 
mPauseButton = (Button) findViewById(R.id.pauseButton); 
mWiFiSettingButton = (Button) findViewById(R.id.wifiSettingsButton); 

mPauseButton.setOnClickListener(this); 
mWiFiSettingButton.setOnClickListener(this); 
(findViewById(R.id.resumeOverCellular)).setOnClickListener(this); 

です

これは、onCreateを期待どおりに実行しますが、何らかの理由でサービスに接続しません。私が言ったように、これは数日前に働いていた、私は何も変更しなかったが、今それは動作しません。

助けが必要ですか?

答えて

0

あなたのサービスのクラス名がDownloaderServiceHelper あるようなので、あなたが

mDownloaderClientStub = DownloaderClientMarshaller.CreateStub(this, DownloaderServiceHelper.class);

mDownloaderClientStub = DownloaderClientMarshaller.CreateStub(this, DownloaderService.class);

からinitializeDownloadUi方法

にコードを変更する必要があるようです

関連する問題