【发布时间】:2017-07-13 08:59:28
【问题描述】:
我已将 Internet 权限代码添加到我的清单中,但我仍然在我的 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 类在这里-
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();
}
}
}
【问题讨论】:
-
您是否在 Android 6 及更高版本的运行时请求了权限?
-
不知道在运行时请求权限。
标签: java android android-manifest