简体   繁体   English

使用Android资源路径获取kml文件?

[英]Get kml-file using android resource path?

Hey, i have a problem, need some help with the path for the kml-file. 嘿,我有问题,需要有关kml文件路径的帮助。 I want to get the path so i can use intent to open the kml-file. 我想获取路径,以便可以使用intent打开kml文件。 It works when i get the the kml from the web, but not when i got it as a resource. 当我从网络上获取kml时,它可以工作,但是当我将其作为资源时,它就不能工作。

Thanks 谢谢

 package test1.test;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MapView.LayoutParams;


public class test11 extends MapActivity {


        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);



            Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
            Uri.parse("geo:0,0?q=android.resource://test1.test/"+R.raw.skikart));
            startActivity(intent);
        }

        @Override
        protected boolean isRouteDisplayed() {
            // TODO Auto-generated method stub
            return false;
        }
    }

use the below code u can get the information from the kmal file 使用以下代码,您可以从kmal文件中获取信息

URLConnection c = mUrl.openConnection();
            c.setConnectTimeout(CONNECTION_TIMEOUT);
            c.setReadTimeout(CONNECTION_TIMEOUT);
            Log.i("URL===", ""+mUrl);
            // write connection to file
            InputStream is = c.getInputStream();

            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(is);
            doc.getDocumentElement().normalize();

            Log.i(TAG,"Root Element: "+doc.getDocumentElement().getNodeName());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM