I'm having trouble opening a file browser window on Android6+. I'm using latest Cordova/PhoneGap with Visual Studio 2017. When I click the desired button, nothing happens. When I deploy my source code on a webserver and access this site on my tablet, everything works fine. A live example can be seen at: http://gipong.github.io/shp2geojson.js/. "Upload zip file" won't open a file browser.
<div class="ui teal fluid labeled icon button upload" id="zipfile" data-content="Mandatory files : SHP , DBF" data-variation="inverted large">
Upload zip file
<i class="file archive outline icon"></i>
<input type="file" id="file" accept=".zip">
</div>
My code (from https://github.com/gipong/shp2geojson.js)
function loadShpZip() {
var epsg = ($('#epsg').val() == '') ? 4326 : $('#epsg').val(),
encoding = ($('#encoding').val() == '') ? 'UTF-8' : $('#encoding').val();
if (file.name.split('.')[1] == 'zip') {
if (file) $('.dimmer').addClass('active');
loadshp({
url: file,
encoding: encoding,
EPSG: epsg
}, function (data) {
var URL = window.URL || window.webkitURL || window.mozURL || window.msURL,
url = URL.createObjectURL(new Blob([JSON.stringify(data)], { type: "application/json" }));
$('#link').attr('href', url);
$('#link').html(file.name + '.geojson' + '<i class="download icon"></i>').attr('download', file.name + '.geojson');
$('#downloadLink').slideDown(400);
$('.shp-modal').toggleClass('effect');
$('.overlay').toggleClass('effect');
$('#wrap').toggleClass('blur');
vector.addData(data);
map.fitBounds([
[data.bbox[1], data.bbox[0]], [data.bbox[3], data.bbox[2]]
]);
$('.dimmer').removeClass('active');
$('#preview').addClass('disabled');
$('#epsg').val('');
$('#encoding').val('');
$('#info').addClass('picInfo');
$('#option').slideUp(500);
newData = data;
for (var i = 0; i < newData.features.length; i++) {
var c1 = newData.features[i].geometry.coordinates;
for (var u = 0; u < c1.length; u++) {
var c2 = c1[u];
for (var o = 0; o < c2.length; o++) {
var oldCoordinate = c2[o];
var newCoordinate = [oldCoordinate[1], oldCoordinate[0]];
c2[o] = newCoordinate;
}
}
}
globaljson = $.parseJSON(JSON.stringify(data));
});
} else {
$('.modal').modal('show');
}
}
initVector();
$("#file").change(function (evt) {
file = evt.target.files[0];
if (file.size > 0) {
$('#dataInfo').text(' ').append(file.name + ' , ' + file.size + ' kb');
$('#option').slideDown(500);
$('#preview').removeClass('disabled');
}
});
$('#preview').click(function () {
loadShpZip();
});
$('.button').popup({
//inline: true,
position: 'bottom left'
});
$('.tips').popup({
target: '#addZipfile',
position: 'top center'
//variation: 'huge'
});
$('#entireLayer').click(function () {
map.fitBounds(vector.getBounds());
chrome.storage.local.set({ 'key': 'value' });
chrome.storage.local.get('key', function (obj) {
alert(obj.key);
});
});
$('#addZipfile').click(function () {
$('.shp-modal').toggleClass('effect');
$('.overlay').toggleClass('effect');
$('#wrap').toggleClass('blur');
});
$('#cancel').click(function () {
$('.shp-modal').toggleClass('effect');
$('.overlay').toggleClass('effect');
$('#wrap').toggleClass('blur');
});
$('#removeLayer').click(function () {
$('#attr').fadeOut(300);
window.location.reload();
});
$('#encoding').dropdown();
$('.v').change(function () {
var msg = '<div class="msg" id="msg" style="display: none;"><div class="ui primary inverted red segment">' +
'<p>You can find the EPSG Code of your Shapefile on <strong>spatialreference.org</strong></p></div><br /></div>';
if ($('#epsg').val().match(/^\d{4}$/) != null) {
$('#zipfile').removeClass('disabled');
$('.msg').slideUp(750);
} else {
if ($('.msg')[0] == undefined) {
$('#epsgField').after(msg);
$('.msg').slideDown(1500);
}
}
});
$("#attr").draggable({ containment: $(this).parent().parent(), scroll: false, cursor: "move" });
$('#cancelAttr').click(function () { $('#attr').hide()
});
I've set my permissions in config.xml like this:
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/*">
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
android:name="android.permission.READ_EXTERNAL_STORAGE" />
</config-file>
</platform>
When I check my app for requested permissions, none show up tho.
This Problem does not exist on a tablet with Android 4.4.
edit: a few logs, which I don't really understand.
07-04 12:10:20.471 18340 18340 W CordovaInterfaceImpl: Got an activity result, but no plugin was registered to receive it.
07-04 12:10:20.471 18340 18340 D WebView : resumeTimers
07-04 12:10:20.471 18340 18340 D WebView : setNetworkAvailable=true
07-04 12:10:20.472 18340 18340 D ActivityThread: SEND_RESULT handled : 0 / ResultData{token=android.os.BinderProxy@7c8f400 results[ResultInfo{who=null, request=5173, result=0, data=null}]}
07-04 12:10:20.482 202 2362 I BufferQueueProducer: [io.cordova.myappac1b3c/io.cordova.myappac1b3c.MainActivity](this:0x7f9222e400,id:306,api:1,p:18340,c:202) queueBuffer: fps=6.96 dur=1149.87 max=176.61 min=134.62
07-04 12:10:20.530 783 1018 D InputReader: AP_PROF:AppLaunch_dispatchPtr:Down:71182195, ID:0, Index:1969346496
07-04 12:10:20.530 783 1018 I PerfService: PerfServiceNative_boostEnableAsync:3
07-04 12:10:20.611 783 1018 D InputReader: AP_PROF:AppLaunch_dispatchPtr:Up:71182277, ID:0, Index:1969349888
07-04 12:10:20.611 783 1018 I PerfService: PerfServiceNative_boostEnableTimeoutMsAsync:3, 100
07-04 12:10:20.696 783 1018 D InputReader: AP_PROF:AppLaunch_dispatchPtr:Down:71182362, ID:0, Index:1969346496
07-04 12:10:20.696 783 1018 I PerfService: PerfServiceNative_boostEnableAsync:3
07-04 12:10:20.766 783 1018 D InputReader: AP_PROF:AppLaunch_dispatchPtr:Up:71182431, ID:0, Index:1969349888
07-04 12:10:20.766 783 1018 I PerfService: PerfServiceNative_boostEnableTimeoutMsAsync:3, 100
07-04 12:10:20.838 783 1018 D InputReader: AP_PROF:AppLaunch_dispatchPtr:Down:71182504, ID:0, Index:1969346496
07-04 12:10:20.838 783 1018 I PerfService: PerfServiceNative_boostEnableAsync:3
07-04 12:10:20.886 783 1017 D PowerManagerService: userActivityFromNative
07-04 12:10:20.887 783 1017 D PowerManagerService: userActivityNoUpdateLocked: eventTime=71182552, event=2, flags=0x0, uid=1000
07-04 12:10:20.887 783 1017 D PowerManagerNotifier: onUserActivity: event=2, uid=1000
07-04 12:10:20.887 783 1017 D PowerManagerService: updateUserActivitySummaryLocked: mWakefulness=Awake, mUserActivitySummary=0x1, nextTimeout=72975552 (in 1792999 ms)
07-04 12:10:20.887 783 1017 D DisplayPowerController: requestPowerState: policy=BRIGHT, useProximitySensor=false, screenBrightness=102, screenAutoBrightnessAdjustment=1.0, brightnessSetByUser=true, useAutoBrightness=true, blockScreenOn=false, lowPowerMode=false, boostScreenBrightness=false, dozeScreenBrightness=-1, dozeScreenState=UNKNOWN, waitForNegativeProximity=false
07-04 12:10:20.887 783 1017 I PowerManagerService: setBrightness mButtonLight 0.
07-04 12:10:20.887 783 1017 D PowerManagerService: updateDisplayPowerStateLocked: mDisplayReady=true, policy=3, mWakefulness=1, mWakeLockSummary=0x23, mUserActivitySummary=0x1, mBootCompleted=true, mScreenBrightnessBoostInProgress=false
07-04 12:10:20.908 783 1018 D InputReader: AP_PROF:AppLaunch_dispatchPtr:Up:71182574, ID:0, Index:1969349888
07-04 12:10:20.908 783 1018 I PerfService: PerfServiceNative_boostEnableTimeoutMsAsync:3, 100
07-04 12:10:20.957 783 1018 D InputReader: AP_PROF:AppLaunch_dispatchPtr:Down:71182623, ID:0, Index:1969346496
07-04 12:10:20.957 783 1018 I PerfService: PerfServiceNative_boostEnableAsync:3
07-04 12:10:21.039 783 1018 D InputReader: AP_PROF:AppLaunch_dispatchPtr:Up:71182705, ID:0, Index:1969349888
07-04 12:10:21.039 783 1018 I PerfService: PerfServiceNative_boostEnableTimeoutMsAsync:3, 100
07-04 12:10:21.080 783 2792 I ActivityManager: START u0 {act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=.zip} from uid 10111 from pid 18340 on display 0
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=.zip }
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1809)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at android.app.Activity.startActivityForResult(Activity.java:3968)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:332)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at android.app.Activity.startActivityForResult(Activity.java:3920)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at org.apache.cordova.CordovaInterfaceImpl.startActivityForResult(CordovaInterfaceImpl.java:67)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at org.apache.cordova.engine.SystemWebChromeClient.onShowFileChooser(SystemWebChromeClient.java:268)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at com.android.webview.chromium.WebViewContentsClientAdapter.showFileChooser(WebViewContentsClientAdapter.java:481)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at org.chromium.android_webview.AwWebContentsDelegateAdapter.runFileChooser(AwWebContentsDelegateAdapter.java:70)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:7)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at android.os.Handler.dispatchMessage(Handler.java:111)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at android.os.Looper.loop(Looper.java:207)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at android.app.ActivityThread.main(ActivityThread.java:5728)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at java.lang.reflect.Method.invoke(Native Method)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
07-04 12:10:21.082 18340 18340 W No activity found to handle file chooser intent.: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
07-04 12:10:21.083 18340 18340 D WebView : setNetworkAvailable=false