Download expansion files on tablet

前端 未结 7 2003
清酒与你
清酒与你 2021-01-28 02:13

I am making an dictionary for android phones and tablets. I have committed the file on my developer account, and i works like a charm on phone. When i am trying to run the exact

相关标签:
7条回答
  • 2021-01-28 02:49

    I have solved the problem. I tok this code and copied instead of the code there where in 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();
      }
    }
    

    I works perfect :D thanks a lot :D

    0 讨论(0)
  • 2021-01-28 03:02

    Slightly less effort would be to download the NotificationCompat2 JAR library and point to that instead.

    0 讨论(0)
  • 2021-01-28 03:04

    I see the same failure on a Toshiba Thrive. The answer from "android developer" works. Basically this means that the download_library was not tested on a V11 device.

    0 讨论(0)
  • 2021-01-28 03:09

    i have the same problem . i have a lead , though:

    if you search for "setProgress" , you can see that it exists on the file "V11CustomNotification" , which is intended (i think ) for API11+ , which includes honeycomb for the tablets.

    "setProgress" is only available for API14+ , so you get an exception.

    now , the question is , how to fix it ...

    there are 2 ways: 1.check if the method exists on "CustomNotificationFactory" , and if not , return the V3CustomNotification instance.

    2.change the code that calls the "setProgress" method , so that it will work for API11..13 (including).

    in any case , please tell us what you've done (exactly) , so that we could all benefit from it.

    i've chosen fix #1 , since it's easier and i didn't succeed with #2 (i tried) : edit the file , and use there the next code:

    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 讨论(0)
  • 2021-01-28 03:09

    I simply added a few lines of code to the com.google.android.vending.expansion.downloader.impl .V11CustomNotification class:

    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
        // ...
        }
    }
    

    It's the answer from "android developer" used in a different way ;)

    0 讨论(0)
  • 2021-01-28 03:11

    @Fuglsang and @android developer's answer works for me, it's perfect...

    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 讨论(0)
提交回复
热议问题