2013-04-20 43 views
0

我正在使用图片从url加载的源代码。图像链接存储在一个json文件中,并将json文件存放在服务器中。但我希望json文件本地存储可能是资产或可绘制的。 我的问题是,如果我使用资产管理器,它必须使用流管理器和流管理器不坐在与加载图像URL的上下文相关的url。 如果我将config_wallpaper_manifest_url的网址更改为loacal资产网址,即。 example.json,同样不会加载。 这可能是什么解决方案?谢谢。在Android中加载带有图片url的本地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(); 
    } 
} 

回答

相关问题