我在具有WebView视图的Android上开发了一个移动应用程序。 在我放入Webview的网站上,有一个可以上传文件的地方,但是当我单击该地方以上传文件时,使用webview没关系。 通常,他应该提供我打开文件管理器的权限,但是我什么也没有。 请帮我 我在下面附上我的网络视图的代码
public class WebViewActivity extends AppCompatActivity {
public String StartUrl = "https://app.vetotrack.com/?tokenPhoneValue=";
public String token;
public String EndUrl = "&tokenPhoneOs=android";
public String Url;
public String getValueToken() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d("tag", "getValueToken: " + refreshedToken);
return refreshedToken;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
getSupportActionBar().hide(); //Cacher le Title Bar
MyFirebaseMessagingService mf = new MyFirebaseMessagingService();
mf.onNewToken(token);
token = getValueToken();
Url = StartUrl + token + EndUrl;
WebView mywebView = findViewById(R.id.myWebView);
WebSettings webSettings = mywebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
mywebView.setWebViewClient(new WebViewClient(){
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.contains("app.vetotrack.com")) {
view.loadUrl(url);
} else {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(i);
}
return true;
}
public void onPageFinished(WebView view, String url){
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl){
Toast.makeText(getApplicationContext(), "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
mywebView.loadUrl(Url);
} }
权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.google.android.c2dm.permission.REGISTER" />
<uses-permission android:name="com.amazonaws.androidtest.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>