【问题标题】:Load local json file with image url in Android在 Android 中加载带有图像 url 的本地 json 文件
【发布时间】:2013-04-20 09:09:44
【问题描述】:

我正在使用从 url 加载图像的源。图像链接存储在 json 文件中,而 json 文件将托管在服务器中。但我希望本地存储的 json 文件可能在资产或可绘制中。 我的问题是,如果我使用资产管理器,它必须使用流管理器,并且流管理器不与 url 一起使用,它与加载图像 url 的上下文相关联。 如果我将 config_wallpaper_manifest_url 的 url 更改为本地资产 url,即。 example.json,同样永远不会加载。 什么是可能的解决方案?谢谢。

public void loadData (Bundle savedInstanceState) {

    // Check Network State
    if (!NetworkUtil.getNetworkState(this)) {
        final RetryFragment fragment = RetryFragment.getFragmentWithMessage("No connection");
        this.addFragment(fragment, RetryFragment.TAG, true);
        return;
    }



    if (savedInstanceState == null || savedInstanceState.get(KEY_LIST_DATA) == null) {
        final String url = super.getResources().getString(R.string.config_wallpaper_manifest_url);
        if (url != null && URLUtil.isValidUrl(url)) {
            // Add Loading Fragment
            final LoadingFragment fragment = new LoadingFragment();
            this.addFragment(fragment, LoadingFragment.TAG, true);

            // Load Data
            final RestClientHandler handler = new RestClientHandler(this);
            RestClient.get(this, url, handler);
        }

    } else {
        Log.i(TAG, "Restored Instance");
        this.mData = (ArrayList<NodeCategory>) savedInstanceState.get(KEY_LIST_DATA);
        this.mPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        if (this.mPosition != -1) {
            mIgnoreSelection = true;
        }

        this.configureActionBar();
    }
}

【问题讨论】:

    标签: android image-loading android-async-http


    【解决方案1】:

    JSON 基本上是文本。将其存储在应用程序的内部存储器中。或者在 SQLite 数据库中。看看这个:

    Creating folder in internal Memory to save files and retrieve them later

    【讨论】:

    • 你建议的方法,我已经试过了。这种方法对 RestclientHandler 产生同样的问题...
    猜你喜欢
    • 2022-01-04
    • 1970-01-01
    • 2012-12-24
    • 1970-01-01
    • 1970-01-01
    • 2012-12-08
    • 1970-01-01
    • 2016-06-08
    • 1970-01-01
    相关资源
    最近更新 更多