自从过去几天以来,我一直在努力从WebView上传文件,但没有任何进展.我用谷歌搜索并实现了所有建议的解决方案,但都没有,例如:此处建议的解决方案,等等.
问题:我有一个带有以下代码的HTML页面来上传文件.它在Firefox等桌面浏览器和模拟器/ AVD的内置浏览器中工作正常,当我点击元素呈现的"浏览..."按钮时,浏览器会打开一个对话框,我可以在其中选择要上传的文件.
但是,在android 3.0模拟器/ AVD中,当我点击"选择文件"时,没有任何反应,没有打开文件对话框!
<form method="POST" enctype="multipart/form-data">
File to upload: <input type="file" name="uploadfile">
<input type="submit" value="Press to Upload..."> to upload the file!
</form>
Run Code Online (Sandbox Code Playgroud)
有人可以最早建议一个可能的解决方案.
它是一个带有Webview的简单WebApp,还有一个带有上载文件选项的注册页面。尝试在单击浏览按钮时打开文件选择器,但没有响应。我认为我的gradle文件中有一些问题。请帮助我调试它。这是我的代码。
这是我的项目gradle
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
这是我的应用程序gradle
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.androidapp.myApp"
minSdkVersion 15
targetSdkVersion 27
versionCode 2
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1' …Run Code Online (Sandbox Code Playgroud)