Open keitheyre opened 2 years ago
Hi @keitheyre, can you share any link you're experiencing this issue with so that we can investigate this?
Thank you
Hey there!
The link is an https firebase storage link, I cannot share as it's private I'm afraid.
I did notice something though, on iOS the files seem to open with no issue. I have followed all the instructions to get them to open on Android but to no avail.
It just opens a white screen and hangs there until I press the back button on the device to return back to the Screen where the Open button is located.
Thank you, Keith
Hi @keitheyre, what type of file is the link supposed to open? Does the link open a browser/webview or another app?
Also, can you confirm if this works in a native android project?
Hi @keitheyre, what type of file is the link supposed to open? Does the link open a browser/webview or another app?
Also, can you confirm if this works in a native android project?
Hey,
the file is a single page PDF. Yes the link opens perfectly on a browser on a computer.
I want the file to be opened in a browser.
Actually I found out today that if I use the launch(url_here) rather than launchUrl() it opens and asks to download or open.
Open -> opens file but when you press back, the app has crashed.
Download -> haven’t tried this yet as it doesn’t work with the flow of my app.
Yes I can confirm the same link works in native android app
I am free to call if you want to discuss this in real-time.
Hi @keitheyre, does this bug still occur if you use LaunchMode.externalApplication
?
Also, is this an issue with only PDF links or generally any link that you get from firestore?
Hey,
I have updated the code to the following:
void launchURL(url) async {
if (await canLaunchUrlString(url)) {
Uri uri = Uri.parse(url);
print(url);
await launchUrl(url, mode: LaunchMode.externalApplication);
} else {
throw 'Could not launch $url';
}
}
The url parameter is a String, a valid url as I have copied and pasted it into an Incognito Browser tab on my Mac. Opens perfectly.
After adding the LaunchMode.externalApplication the results are:
PDF:
PNG:
.doc
Different .pdf
Same problem as above. the back button is returning to a white app screen with no errors other than Lost connection
Hi @keitheyre, thanks for the extra information.
I found a firebase storage URL somewhere online and I was able to reproduce the white screen. Below are my observations
LaunchMode.externalApplication
/LaunchMode.externalNonBrowserApplication
LaunchMode.platformDefault
launched URL in a webview and the PDF was properly displayedLaunchMode.platformDefault
or LaunchMode.inAppWebview
I haven't tested opening a webview in native android yet, so there's a chance this issue might be reproducing when using the webview option in native android as well.
Will investigate that later and report back.
For now, leaving this for further insight from the team.
Hi @danagbemava-nc
I have confirmed on my end with our Native Android App that the same links work but we handled it differently within our Android App. We instead check the type of file and decide what to do then.
Am I right in saying there is an issue here with the package? Should I wait for an update or go ahead and implement another solution for the above task?
Thanks again, Keith
I also experience this issue, everything same as above mentioned. In my case it mostly happens when url is pointing to online pdf file.
Actually I found out today that if I use the launch(url_here) rather than launchUrl() it opens and asks to download or open.
By default I believe launch
will use an external browser in Android, whereas launchUrl
will open in the app, which may explain this difference.
Actually I found out today that if I use the launch(url_here) rather than launchUrl() it opens and asks to download or open.
By default I believe
launch
will use an external browser in Android, whereaslaunchUrl
will open in the app, which may explain this difference.
I have tried all LaunchModes and ended up making my own custom camera manager for Android to combat this issue.
I have read that certain devices are prone to this problem but we are locked in with this specific device.
If there is any fixes in the future I would greatly appreciate an email Thanks
keith
The most likely explanation based on the repro description is that we need an extra delegate wired up for the in-app webview to deal with unhandled content (e.g., to prompt to download). If that's the case, we'll need to figure out how to manage this without the in-app version becoming as complex as webview_flutter
itself.
Im facing the same issue. It works great in case of iOS Apps. the Url opens up the PDF file. But in case of Android the user is shown a blank white screen. In case of setting the launch mode to external application the user is taken to the Browser and the file is being downloaded. This is not the experience I was looking for. I'm looking for something similar to iOS.
Have raised an issue on stack overflow as well. https://stackoverflow.com/questions/73733310/flutter-url-launcher-showing-white-screen-for-pdf-file-on-gcp-storage-android
Some logs which might be useful
/UrlLauncher(24742): component name for https://storage.googleapis.com/files/FAKE_FILE.pdf is {com.android.chrome/com.google.android.apps.chrome.IntentDispatcher}
I/ViewRootImpl@67ff2f9[MainActivity](24742): MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputTransport(24742): Input channel destroyed: 'ClientS', fd=128
I/ViewRootImpl@67ff2f9[MainActivity](24742): handleAppVisibility mAppVisible=true visible=false
I/SurfaceView@901753(24742): onWindowVisibilityChanged(8) false io.flutter.embedding.android.FlutterSurfaceView{901753 V.E...... ........ 0,0-1080,2274} of ViewRootImpl@67ff2f9[MainActivity]
I/SurfaceView@901753(24742): pST: mTmpTransaction.apply, mTmpTransaction = android.view.SurfaceControl$Transaction@9262987
I/SurfaceView@901753(24742): surfaceDestroyed callback.size 1 #2 io.flutter.embedding.android.FlutterSurfaceView{901753 V.E...... ........ 0,0-1080,2274}
I/SurfaceView@901753(24742): updateSurface: mVisible = false mSurface.isValid() = true
I/SurfaceView@901753(24742): tryReleaseSurfaces: set mRtReleaseSurfaces = true
I/SurfaceView@901753(24742): 96460965 wPL, frameNr = 0
I/SurfaceView@901753(24742): remove() from RT android.view.SurfaceView$SurfaceViewPositionUpdateListener@5bfe0a5 Surface(name=SurfaceView - com.pyjamahr.pyjamahr/com.pyjamahr.pyjamahr.MainActivity@901753@3)/@0xdc31c7a
I/SurfaceView@901753(24742): remove() io.flutter.embedding.android.FlutterSurfaceView{901753 V.E...... ........ 0,0-1080,2274} Surface(name=SurfaceView - com.pyjamahr.pyjamahr/com.pyjamahr.pyjamahr.MainActivity@901753@3)/@0xdc31c7a
I/SurfaceView@901753(24742): aOrMT: uB = true t = android.view.SurfaceControl$Transaction@8c1a60 fN = 0 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionLost:1785 android.graphics.RenderNode$CompositePositionUpdateListener.positionLost:326
I/SurfaceView@901753(24742): aOrMT: vR.mWNT, vR = ViewRootImpl@67ff2f9[MainActivity]
I/ViewRootImpl@67ff2f9[MainActivity](24742): mWNT: t = android.view.SurfaceControl$Transaction@8c1a60 fN = 0 android.view.SurfaceView.applyOrMergeTransaction:1628 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionLost:1785
I/ViewRootImpl@67ff2f9[MainActivity](24742): mWNT: merge t to BBQ
D/OpenGLRenderer(24742): setSurface called with nullptr
D/OpenGLRenderer(24742): setSurface() destroyed EGLSurface
D/OpenGLRenderer(24742): destroyEglSurface
I/ViewRootImpl@302c854[MainActivity](31905): Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)8 dur=4 res=0x5 s={false 0} ch=true fn=2
I/SurfaceView@901753(31905): windowStopped(true) false io.flutter.embedding.android.FlutterSurfaceView{901753 V.E...... ........ 0,0-1080,2274} of ViewRootImpl@302c854[MainActivity]
2
D/SurfaceView@901753(31905): updateSurface: surface is not valid
I/ViewRootImpl@302c854[MainActivity](31905): stopped(true) old=false
D/SurfaceView@901753(31905): updateSurface: surface is not valid
Actually I found out today that if I use the launch(url_here) rather than launchUrl() it opens and asks to download or open.
By default I believe
launch
will use an external browser in Android, whereaslaunchUrl
will open in the app, which may explain this difference.
@stuartmorgan I think the launch was for opening the external application whereas the launchUrl is by default using PlatformDefault intent. which is to open an in App web view both in case of Android and iOS. We have to change and set the mode to LaunchMode.externalApplication to open the url in external browser in case of launchUrl.
This is not the experience I was looking for. I'm looking for something similar to iOS.
You can't get the same experience on Android, because Android webview doesn't display PDFs. The resolution for this issue would be a callback about unsupported content, so that you could handle it however you like.
I have more or less the same issue.
I'm trying to open a web link (https://my/url.com
)
Is there any progress or possible workout for this ? How would we handle files in android using the inAppWebView or platformDefault mode ?
Is there any progress or possible workout for this ? How would we handle files in android using the inAppWebView or platformDefault mode ?
In my case, using the deprecated launch
is working.
@ValentinVignal launch opens in an external browser, i need the in app browser to maintain an SSO session so this is not a solution for me
I'm having the same issue opening PDF documents only in Android. iOS, MacOS, Web works fine.
main.dart
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher_string.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextButton(onPressed: () => launchUrlString('https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf'), child: const Text('launchUrlString')),
],
),
),// This trailing comma makes auto-formatting nicer for build methods.
);
}
}
pubspec.yml
name: url_test
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=2.18.6 <3.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
url_launcher: ^6.1.7
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
AndroidManifest.xml (normal manifest with queries section added)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.url_test">
<application
android:label="url_test"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<queries>
<!-- Intent for opening https URLs in the browser. -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
</manifest>
Same situation over here.... I get just a white window when pdf wants to be launched...
It was working fine in my previous app release :( .. but broken after new release
@ValentinVignal reply is also my working workaround.
In my case, using the deprecated
launch
is working.
See https://github.com/flutter/flutter/issues/105205#issuecomment-1248938994. You just need to specify the correct launch mode to the current API, you don't need to use the deprecated API (which defaulted to that launch mode on Android).
@stuartmorgan thanks... did not reach that part of the post :) ... working fine again on latest vers.
I've also got this issue on android the pdf is not rendered just downloaded.
I've tried both methods of launching and the issue still persists.
await launchUrlString(
url!,
mode: LaunchMode.externalApplication,
webViewConfiguration: WebViewConfiguration(
enableJavaScript: true,
enableDomStorage: true,
),
);
await launchUrl(
Url,
mode: LaunchMode.externalApplication,
webViewConfiguration: WebViewConfiguration(
enableJavaScript: true,
enableDomStorage: true,
),
);
@BrendanBasson4 This issue is about nothing happening when using the in-app webview. If you are opening in an external browser and it opened (which is did if it's downloading), then url_launcher
worked correctly. What the browser does with the PDF is up to the browser at that point. If you think it should display the PDF you'll need to file an issue with the developers of your browser.
If I try to open a Link to a PDF in the Browser (LaunchMode.externalApplication
) nothing happens.
When I do the same thing with a Link to an HTML File everything works as expected. (The Page is opened in the default Browser.)
This Error only happens on Android. On iOS everything works as expected. This is my code:
if (await canLaunchUrl(Uri.parse(url))) {
print('can launch this shit');
}
print('url: ' + url.toString());
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
The Code inside the if statement is executed but no Browser is opening. Nothing happens when i try to open a url pointing to a PDF File.
@TimAlber Please file a new issue; this is about the in-app webview move.
I think the route to fixing this issue is probably for us to switch to using a Chrome custom tab for LaunchMode.inAppWebView
(and therefore by default), instead of a hand-rolled webview window:
Anyone affected by this issue can flutter pub upgrade
to pick up url_launcher_android
6.1.0 or later, and in supported configurations in-app mode will use Custom Tabs instead of the previous webview, which won't have this issue.
you have to append "https://docs.google.com/gview?embedded=true&url=" before your Url , in android only IOS will manage it self
You can also use this
final url = "https://docs.google.com/gview?embedded=true&url=${widget.webUrl}"
void launchURL(url) async {
if (await canLaunchUrlString(url)) {
Uri uri = Uri.parse(url);
print(url);
await launchUrl(url, mode: LaunchMode.inAppWebView);
} else {
throw 'Could not launch $url';
}
}
Removing priority label for re-triage.
you have to append "https://docs.google.com/gview?embedded=true&url=" before your Url , in android only IOS will manage it self
You can also use this
final url = "https://docs.google.com/gview?embedded=true&url=${widget.webUrl}" void launchURL(url) async { if (await canLaunchUrlString(url)) { Uri uri = Uri.parse(url); print(url); await launchUrl(url, mode: LaunchMode.inAppWebView); } else { throw 'Could not launch $url'; } }
Is it possible to use authorization headers with this approach?
Running on Android physical device - (Galaxy Tab A7 - WiFi) url_launcher: ^6.1.2 Android Studio Bumblebee | 2021.1.1 Patch 3
Issue: I am trying to open a Firebase Storage URL from the device using the following code:
This is the result:
flutter doctor -v
``` [✓] Flutter (Channel stable, 2.10.5, on macOS 12.4 21F79 darwin-x64, locale en-IE) • Flutter version 2.10.5 at /Users/keitheyre/Documents/DEV/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5464c5bac7 (6 weeks ago), 2022-04-18 09:55:37 -0700 • Engine revision 57d3bac3dd • Dart version 2.16.2 • DevTools version 2.9.2 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/keitheyre/Library/Android/sdk • Platform android-31, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.4) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822) [✓] Connected device (2 available) • SM T510 (mobile) • R52MA1ESSTY • android-arm • Android 11 (API 30) • Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.99 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```