【问题标题】:How to minimizing android app cache size如何最小化android应用缓存大小
【发布时间】:2016-12-07 15:18:48
【问题描述】:

当我将应用程序加载到设备中时,我的 android 应用程序缓存大小约为 40MB,并且在第一次启动应用程序时显示空白屏幕。我不知道如何解决这个挑战,请帮忙。

这些是我正在使用的库。

compile(group: 'com.microsoft.azure', name: 'azure-notifications-handler', version: '1.0.1', ext: 'jar')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.microsoft.azure.android:azure-storage-android:0.6.0@aar'
compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'

【问题讨论】:

    标签: android caching launching


    【解决方案1】:

    我会尝试this guide 您可能无法在其中放置动画,但是当您的应用第一次加载时显示一些资源而不是黑/白屏幕听起来不错。

    【讨论】:

    • 非常感谢@parohy :) 帮助我在应用程序的冷启动时提供更好的用户体验。不幸的是,没有足够的声誉来投票...再次感谢
    【解决方案2】:

    在应用加载时,您需要某种启动画面来娱乐用户。但是有一个问题......因为应用程序仍在加载中,它如何运行任何代码来显示启动画面?实际上不能,但幸运的是,有一个解决方案:在加载期间,窗口管理器使用主题中的元素(例如背景和状态栏颜色)为您的应用程序绘制一个占位符 UI。正确设置主题允许您即刻显示静态图像(尚未加载代码,因此此时没有花哨的动画)。关键是创建覆盖android:windowBackground 属性的自定义主题,一旦您的应用程序加载并开始运行,您只需将该主题替换为标准主题,然后在您的活动中调用super.onCreate()

    这是 Ian Lake 的 Google+ 帖子,详细描述了这种技术:Use cold start time effectively with a branded launch theme

    【讨论】:

    • 感谢@Marcin Orlowski 的回复,我会试试看.. 有没有办法减少应用程序缓存内存消耗...
    • 尝试使用 ProGuard 去除包含库中未使用的部分(在项目设置中称为“缩小”)。还要检查这个:tools.android.com/tech-docs/new-build-system/resource-shrinking
    • 非常感谢,效果很好。我对我的应用程序在加载时的响应感到非常惊讶,30 秒到不到 2 秒 :) 不幸的是没有足够的声誉来投票......谢谢。
    猜你喜欢
    • 1970-01-01
    • 2012-02-08
    • 2012-01-28
    • 2011-02-25
    • 2017-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多