2012-03-21 14 views
0

私はアンドロイドの携帯電話とタブレットの辞書を作っています。私は自分の開発者アカウントでファイルをコミットしました。私は電話での魅力のように動作します。私がSamsungの銀河タブ10.1で全く同じコードを実行しようとしているとき、それは止まっています。タブレットで拡張ファイルをダウンロード

 if (!expansionFilesDelivered()) { 

     try { 
        Intent launchIntent = SampleDownloaderActivity.this.getIntent(); 
        Intent intentToLaunchThisActivityFromNotification = new Intent(SampleDownloaderActivity.this, SampleDownloaderActivity.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(SampleDownloaderActivity.this, 0, intentToLaunchThisActivityFromNotification, PendingIntent.FLAG_UPDATE_CURRENT); 
        // Request to start the download 

        NotificationManager nm = (NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE); 

        int startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(this, pendingIntent, SampleDownloaderService.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(); 
     } 

    } 

それは、この例外が付属しています:私はダウンロードを文句を言わない理由

03-21 15:24:45.940: I/ApplicationPackageManager(17750): cscCountry is not German : NEE 
03-21 15:24:46.000: D/dalvikvm(17750): GC_CONCURRENT freed 347K, 7% free 6569K/7047K, paused 3ms+3ms 
03-21 15:24:47.280: E/Environment(17750): getExternalStorageState/mnt/sdcard 
03-21 15:24:47.370: W/LVLDL(17750): Exception for main.2.dk.letsoftware.KFEnglish.obb: java.lang.NoSuchMethodError: android.app.Notification$Builder.setProgress 
03-21 15:37:29.480: I/ApplicationPackageManager(17750): cscCountry is not German : NEE 
03-21 15:37:29.950: D/dalvikvm(17750): GC_CONCURRENT freed 217K, 5% free 6768K/7111K, paused 3ms+6ms 
03-21 15:37:30.650: E/Environment(17750): getExternalStorageState/mnt/sdcard 
03-21 15:37:30.760: W/LVLDL(17750): Exception for main.2.dk.letsoftware.KFEnglish.obb: java.lang.NoSuchMethodError: android.app.Notification$Builder.setProgress 
03-21 15:37:40.410: D/CLIPBOARD(17750): Hide Clipboard dialog at Starting input: finished by someone else... ! 
03-21 15:40:24.870: D/dalvikvm(17750): GC_EXPLICIT freed 239K, 7% free 6619K/7111K, paused 2ms+2ms 
03-21 15:41:51.140: I/ApplicationPackageManager(17750): cscCountry is not German : NEE 
03-21 15:41:51.560: E/Environment(17750): getExternalStorageState/mnt/sdcard 
03-21 15:41:51.660: W/LVLDL(17750): Exception for main.2.dk.letsoftware.KFEnglish.obb: java.lang.NoSuchMethodError: android.app.Notification$Builder.setProgress 

私は見当がつかない。その画面が来る前に、それは私がそれを見ることができることを知っているファイルのサイズを示しています。

おかげでよろしくお願いします。

+0

"それは固まっている"と言えば、どこでデバッグを始めるのですか?明白な問題点はありますか? – HaemEternal

+0

それは完全に行きますが、決してダウンロードを開始しません。それは単に "開始"で画面を表示し続けます。通知を押すと、もう一度やり直します。 – Fuglsang

+0

FYIもしあなたがプロジェクトの上で 'Lint'を走らせたなら、これを選んだでしょう。 – Blundell

答えて

3

私は同じ問題があります。

"setProgress"を検索した場合、それはタブレットのハニカムを含むAPI11 +用の「V11CustomNotification」ファイルに存在することがわかります。

「setProgress」はAPI14 +でのみ使用できるため、例外が発生します。この方法は、「CustomNotificationFactory」上に存在する 1.check場合は、そうでない場合、V3CustomNotificationインスタンスを返します。

今、質問があり、それを修正する方法を...

は2通りの方法があります。

2.「setProgress」メソッドを呼び出すコードを変更し、API11.1.13(including)で機能するようにします。

いずれにしても、あなたが行ったことを(正確に)教えてください。そうすれば、私たちはすべてそれから利益を得ることができます。

私は、修正#1を選んだ、それは簡単だと私は#2で成功しなかったので、(私が試した): 編集ファイル、およびそこに次のコードを使用します。私は見

static public DownloadNotification.ICustomNotification createCustomNotification() 
{ 
    try 
    { 
    final Class<?> notificationBuilderClass = Class.forName("android.app.Notification$Builder"); 
    notificationBuilderClass.getDeclaredMethod("setProgress", new Class[] {Integer.TYPE, Integer.TYPE, Boolean.TYPE}); 
    return new V11CustomNotification(); 
    } 
    catch (final Exception e) 
    { 
    return new V3CustomNotification(); 
    } 
} 
0

を東芝が繁栄するのと同じ失敗。 「アンドロイドデベロッパー」からの回答が機能します。基本的に、これは、download_libraryがV11デバイスでテストされなかったことを意味します。

1

私はこの問題を解決しました。 が、私はこのコードをTOK、代わりにそこCustomNotificationFactory

static public DownloadNotification.ICustomNotification createCustomNotification() 
{ 
    try 
    { 
    final Class<?> notificationBuilderClass = Class.forName("android.app.Notification$Builder"); 
    notificationBuilderClass.getDeclaredMethod("setProgress", new Class[] {Integer.TYPE, Integer.TYPE, Boolean.TYPE}); 
    return new V11CustomNotification(); 
    } 
    catch (final Exception e) 
    { 
    return new V3CustomNotification(); 
    } 
} 

のコードをコピーした私は完璧に動作します:Dのおかげでたくさん:D

2

私は単にcom.googleに数行のコードを追加しました。 android.vending.expansion.downloader.impl .V11CustomNotificationクラス:

public class V11CustomNotification implements DownloadNotification.ICustomNotification { 
// ... 
    boolean hasSetProgressFunction = false; // Added 
    boolean hasCheckedForSetProgressFunction = false; // Added 

    public void CheckForFunction() { // Added 
     try { 
      final Class<?> notificationBuilderClass = Class.forName("android.app.Notification$Builder"); 
      notificationBuilderClass.getDeclaredMethod("setProgress", new Class[] {Integer.TYPE, Integer.TYPE, Boolean.TYPE}); 
      this.hasSetProgressFunction = true; 
     } catch (final Exception e) { 
      this.hasSetProgressFunction = false; 
     } 
     this.hasCheckedForSetProgressFunction = true; 
    } 
// ... 
    @Override 
    public Notification updateNotification(Context c) { 
     if(!this.hasCheckedForSetProgressFunction) { // Added 
      this.CheckForFunction(); // Added 
     } // Added 
    // ... 
      builder.setContentTitle(mTitle); 
      if(this.hasSetProgressFunction) { // Added 
       if (mTotalKB > 0 && -1 != mCurrentKB) { 
        builder.setProgress((int)(mTotalKB>>8), (int)(mCurrentKB>>8), false); 
       } else { 
        builder.setProgress(0,0,true); 
       } 
      } // Added 
    // ... 
    } 
} 

それは別の方法で使用される「アンドロイド開発者」からの回答です。)

1

@Fuglsangと@android開発者の答えは私のために動作しますが、それは完璧です...

static public DownloadNotification.ICustomNotification createCustomNotification() 
{ 
    try 
    { 
    final Class<?> notificationBuilderClass = Class.forName("android.app.Notification$Builder"); 
    notificationBuilderClass.getDeclaredMethod("setProgress", new Class[] {Integer.TYPE, Integer.TYPE, Boolean.TYPE}); 
    return new V11CustomNotification(); 
    } 
    catch (final Exception e) 
    { 
    return new V3CustomNotification(); 
    } 
} 
0

わずかに少ない労力ではなく、それにNotificationCompat2のJARライブラリとポイントをダウンロードすることであろう。

2

タブレット(Android 3搭載のギャラクシータブ)の通知に問題がありました。 android-support-v4.jarリビジョン10のNotificationCompatユーティリティがこのエラーをスローします。おそらくサポートライブラリのバグです。

java.lang.NoSuchMethodError: android.app.Notification$Builder.setProgress 
at android.support.v4.app.NotificationCompatIceCreamSandwich.add(NotificationCompatIceCreamSandwich.java:31) 
at android.support.v4.app.NotificationCompat$NotificationCompatImplIceCreamSandwich.build(NotificationCompat.java:104) 
at android.support.v4.app.NotificationCompat$Builder.build(NotificationCompat.java:558) 

この修復されたサポートライブラリrevを使用してこの問題を解決しました。 10:http://code.google.com/p/yuku-android-util/source/browse/ActionBarSherlock4/libs/android-support-v4.jar。このJARを使うと、うまく動作します。 yukukuへ

ありがとう:http://code.google.com/p/android/issues/detail?id=36359

EDIT:新Support Library, revision 11 (November 2012)修正この問題。

関連する問題