Download expansion files on tablet

前端 未结 7 2007
清酒与你
清酒与你 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 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 ;)

提交回复
热议问题