尽管添加了互联网许可,但我的 logcat 中得到了 "No Network Security Config specified, using platform default"

despite of adding internet permission i'am getting "No Network Security Config specified, using platform default" in my logcat

我已将互联网许可代码添加到我的清单中,但我的 logcat 中仍然得到 No Network Security Config specified, using platform default。通过我的代码,我试图在按下按钮时从 url 获取 html 代码,但不幸的是我的应用程序崩溃了。 我在这里粘贴我的清单代码:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rekhahindwar.linksaver" >
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity android:name=".UrlFetcher" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

我的 java class 在这里-

public class UrlFetcher extends AppCompatActivity implements View.OnClickListener {

EditText url;
Button fetch;
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initialize();
}

private void initialize() {
    url = (EditText) findViewById(R.id.url);
    fetch = (Button) findViewById(R.id.fetch);
    fetch.setOnClickListener(this);
}

@Override
public void onClick(View v) {
    String baseurl = url.getText().toString();
    Document doc = null;
    try {
        doc = Jsoup.connect(baseurl).get();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
}

也许你的防火墙阻止了连接,禁用它并重试,我也认为你可能需要将它添加到你的清单 xml 文件中,因为你正在使用 jsoup 来解析一些 html

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

在下面创建一个单独的异步任务class。 并使用它从 activity 调用您的异步 class。

new FetchURLAsyncTask().execute();



public class FetchURLAsyncTask extends AsyncTask<Void, Void, Void> {
    @Override
    protected Void doInBackground(Void... params) {
        StringBuffer buffer = new StringBuffer();
        try {
            Document doc = Jsoup.connect("https://www.google.co.in").get();
            String title = doc.title();
            System.out.println("Url !!!! " + title);
        }
        catch(Throwable t) {
            t.printStackTrace();
        }
        return null;
    }
}