下载平板电脑上的扩展文件 [英] Download expansion files on tablet
问题描述
我想提出一个字典为Android手机和平板电脑。我犯了我的开发者账号的文件,我就像在手机的魅力。当我试图在我的三星Galaxy Tab 10.1的运行完全相同,code,它被卡住。
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 exactly same code on my samsung galaxy tab 10.1, it is stuck.
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();
}
}
它配备了这个异常:
It comes with this exception :
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
我不知道为什么我不会下载。在此之前,屏幕上出现,它显示了文件Sa的尺寸我知道我能本身它。
I have no idea why i wont download. Before that screen comes, it shows the size of the file så i know that i can se it.
请帮帮我,谢谢
推荐答案
我有同样的问题。 我有一个领导,但:
i have the same problem . i have a lead , though:
如果你搜索setProgress,你可以看到,它存在于文件V11CustomNotification,其目的是(我认为)为API11 +,其中包括蜂窝的平板电脑。
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仅适用于API14 +,所以你得到一个异常。
"setProgress" is only available for API14+ , so you get an exception.
现在的问题是,如何解决它?
now , the question is , how to fix it ...
有2种方式: 1,检查方法上存在CustomNotificationFactory,如果没有,则返回V3CustomNotification实例
there are 2 ways: 1.check if the method exists on "CustomNotificationFactory" , and if not , return the V3CustomNotification instance.
2.change的code调用setProgress的方法,使之工作API11..13(含)。
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.
我选择修复#1,因为它更容易,我没有用#2(我想)成功: 编辑该文件,并使用有下一个code:
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();
}
}
这篇关于下载平板电脑上的扩展文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!