2012-03-21 8 views
0

나는 android phones and tablets에 대한 사전을 만들고 있습니다. 개발자 계정에서 파일을 커밋했습니다. 휴대 전화의 매력처럼 작동합니다. 내 삼성 갤럭시 탭 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"를 검색하면 해당 파일이 "V11CustomNotification"파일에 있음을 알 수 있습니다.이 파일은 API11 + 용으로 벌집이 포함되어 있습니다.

"setProgress"는 API14 +에서만 사용할 수 있으므로 예외가 발생합니다. 이 방법은 "CustomNotificationFactory"에 존재 1.check 경우와하지 않는 경우는 V3CustomNotification 인스턴스를 반환 :

지금, 질문은, 그것을 해결하는 방법을 ...

2 가지 방법이 있습니다.

2. "setProgress"메소드를 호출하는 코드를 변경하여 API11.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

을 Toshiba에서 동일한 실패는 번성한다. "android developer"의 답변이 작동합니다. 기본적으로 이것은 download_library가 V11 장치에서 테스트되지 않았 음을 의미합니다.

1

나는이 문제를 해결했다. 는 내가 완벽 작동 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

편집 : 새로운 Support Library, revision 11 (November 2012) 수정이 문제를 해결합니다.

관련 문제