Swift Open Link in Safari

It’s not “baked in to Swift”, but you can use standard UIKit methods to do it. Take a look at UIApplication’s openUrl(_:) (deprecated) and open(_:options:completionHandler:). Swift 4 + Swift 5 (iOS 10 and above) guard let url = URL(string: “https://stackoverflow.com”) else { return } UIApplication.shared.open(url) Swift 3 (iOS 9 and below) guard let url = … Read more

Android webview slow

It depends on the web application being loaded. Try some of the approaches below: Set higher render priority (deprecated from API 18+): webview.getSettings().setRenderPriority(RenderPriority.HIGH); Enable/disable hardware acceleration: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // chromium, enable hardware acceleration webView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } else { // older android version, disable hardware acceleration webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } Disable the cache (if … Read more

File Upload in WebView

This is a full solution for all android versions, I had a hard time with this too. public class MyWb extends Activity { /** Called when the activity is first created. */ WebView web; ProgressBar progressBar; private ValueCallback<Uri> mUploadMessage; private final static int FILECHOOSER_RESULTCODE=1; @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if(requestCode==FILECHOOSER_RESULTCODE) … Read more

How to check if a file exists in Documents folder?

Swift 3: let documentsURL = try! FileManager().url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true) … gives you a file URL of the documents directory. The following checks if there’s a file named foo.html: let fooURL = documentsURL.appendingPathComponent(“foo.html”) let fileExists = FileManager().fileExists(atPath: fooURL.path) Objective-C: NSString* documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; NSString* foofile = [documentsPath stringByAppendingPathComponent:@”foo.html”]; BOOL … Read more