SuperBrowser简单游览器Android
1.AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.glsite.superbrowser">
<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"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:scheme="about" />
<data android:scheme="javascript" />
</intent-filter>
</activity>
</application>
</manifest>
2.新建 SuperBrowser\app\src\main\res\xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
3.MainActivity.java
package com.glsite.superbrowser;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
private EditText mEtPath;
private ImageView mIvGo;
private WebView mWv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mEtPath = findViewById(R.id.et_path);
mIvGo = findViewById(R.id.iv_go);
mWv = findViewById(R.id.wv);
Intent intent = getIntent();
if (intent != null) {
if (intent.getData() != null) {
String path = intent.getData().toString();
mWv.loadUrl(path);
mEtPath.setText(path);
}
}
mIvGo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String path = mEtPath.getText().toString().trim();
mWv.loadUrl(path);
}
});
}
}