微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何访问http://schemas.android.com/apk/res/android?

如何解决如何访问http://schemas.android.com/apk/res/android?

在开发android时,我们通常在开发布局文件时使用xml。

示例)

  @RequiresApi(api = Build.VERSION_CODES.N)
        private void video() throws IOException {
            youTubePlayerView.setVisibility(View.VISIBLE);
            try {
                HttpClient client = new DefaultHttpClient(getHttpRequestParams());
                HttpGet getJson = new HttpGet(SERVER_ADRESS + "instruments.json");
                HttpResponse jsonResponse = client.execute(getJson);

                if (200 == jsonResponse.getStatusLine().getStatusCode()) {
                    InputStream inputStream = jsonResponse.getEntity().getContent();
                    String json = IoUtils.toString(inputStream);
                    Instrument[] instrumentsResult = new Gson().fromJson(json,Instrument[].class);
                    instrumentsResult = Arrays.stream(instrumentsResult).filter(x -> x.analysename.equals(instrumentname)).toArray(Instrument[]::new);
                    String youtube = instrumentsResult[0].youtube;
                    onInitializedListener = new YouTubePlayer.OnInitializedListener() {
                        @Override
                        public void onInitializationSuccess(YouTubePlayer.Provider provider,YouTubePlayer youTubePlayer,boolean b) {
                            youTubePlayer.loadVideo(youtube);                        }
                        @Override
                        public void onInitializationFailure(YouTubePlayer.Provider provider,YouTubeInitializationResult youTubeInitializationResult) {  }                    };
                    button.setonClickListener(new View.OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            setContentView(R.layout.activity_main);
                            youTubePlayerView = findViewById(R.id.youtube_view);
                            youTubePlayerView.initialize("AIzaSyAwfhwUwcdwcgp8fd8DCPIS-UVQqVtgpog",onInitializedListener);           } }
                            );  }




            } catch (IOException e) {
                e.printstacktrace();
            } catch (UnsupportedOperationException e) {
                e.printstacktrace();
            } catch (JsonSyntaxException e) {
                e.printstacktrace();
            }
        }


        @RequiresApi(api = Build.VERSION_CODES.N)
        private void video2() throws IOException {
            youTubePlayerView.setVisibility(View.VISIBLE);
            try {
                HttpClient client = new DefaultHttpClient(getHttpRequestParams());
                HttpGet getJson = new HttpGet(SERVER_ADRESS + "instruments.json");
                HttpResponse jsonResponse = client.execute(getJson);

                if (200 == jsonResponse.getStatusLine().getStatusCode()) {
                    InputStream inputStream = jsonResponse.getEntity().getContent();
                    String json = IoUtils.toString(inputStream);
                    Instrument[] instrumentsResult2 = new Gson().fromJson(json,Instrument[].class);
                    instrumentsResult2 = Arrays.stream(instrumentsResult2).filter(x -> x.analysename.equals(instrumentname2)).toArray(Instrument[]::new);
                    String youtube2 = instrumentsResult2[0].youtube;
                    onInitializedListener2 = new YouTubePlayer.OnInitializedListener() {
                        @Override
                        public void onInitializationSuccess(YouTubePlayer.Provider provider,boolean b) {
                            youTubePlayer.loadVideo(youtube2);                        }
                        @Override
                        public void onInitializationFailure(YouTubePlayer.Provider provider,YouTubeInitializationResult youTubeInitializationResult) {  }                    };
                    button2.setonClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            setContentView(R.layout.activity_main);
                            youTubePlayerView = findViewById(R.id.youtube_view);
                            youTubePlayerView.initialize("AIzaSyAwfhwUwcdwcgp8fd8DCPIS-UVQqVtgpog",onInitializedListener2);           } });  }




            } catch (IOException e) {
                e.printstacktrace();
            } catch (UnsupportedOperationException e) {
                e.printstacktrace();
            } catch (JsonSyntaxException e) {
                e.printstacktrace();
            }
        }

我当时有一个查询。 如何访问http://schemas.android.com/apk/res/android

我发现了一些信息。 我知道这不是URL,而是URI。因此无法通过互联网访问。那么名称空间信息在哪里?如何访问该信息?

解决方法

根据Namespaces in XML 1.0 (Third Edition),以下URI是命名空间名称

http://schemas.android.com/apk/res/android

3 Declaring Namespaces 部分中指出:

为了达到其预期目的,名称空间名称应具有唯一性和持久性的特征。它不是可直接用于模式检索(如果存在)的目标。

某些XML没有架构。在此类XML中,您无法拥有它。

名称空间名称的目的是避免元素名称和属性名称发生冲突。 XML使用URI作为其唯一性和持久性的名称空间名称。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。