Hello I'm giving a flow a try that would open an html file. However, Automagic's selection for the file recognizes it as a text file. Is there a way to pull the default web browser as a variable? This variable would be passed to the action "Open URL in browser."
I have tried:
Executing shell command to use internal webview browser. This results in permissions error.
Searching through global, local, and system init variables.
Entering "html://" for the file location prefix.
Thank you for any insight and your time.
Launching default internet browser
Moderator: Martin
Re: Launching default internet browser
Code: Select all
browserIntent = callJavaConstructor("android.content.Intent", "Intent(java.lang.String, android.net.Uri)", "android.intent.action.VIEW", callJavaStaticMethod("android.net.Uri", "parse(java.lang.String)", "http://"));
resolveInfo = callJavaMethod(callJavaMethod(getContext(), "android.content.Context", "getPackageManager()"), "android.content.pm.PackageManager", "resolveActivity(android.content.Intent, int)", browserIntent, getJavaStaticField("android.content.pm.PackageManager", "MATCH_DEFAULT_ONLY"));
packageName = getJavaField(getJavaField(resolveInfo, "android.content.pm.ResolveInfo", "activityInfo"), "android.content.pm.ActivityInfo", "packageName");
Re: Launching default internet browser
This seems to work well, thank you for the great solution. However, with "View Web URL Intent Received" the default browser happens to be Automagic. When trying to send a link to a file, Automagic will not parse it using the web browser. Instead it throws an error. It seems the "Open URL in browser" is a little misleading because it doesn't actually attempt to open all paths in the browser if it so happens to be a file. It seems to first check with the system which app is most suitable. With advances in web browsers this action should attempt to open everything including files in the default web browser. This may be a bug with Automagic but not for certain?anuraag wrote: ↑13 Oct 2019 04:36packageName will contain your required variableCode: Select all
browserIntent = callJavaConstructor("android.content.Intent", "Intent(java.lang.String, android.net.Uri)", "android.intent.action.VIEW", callJavaStaticMethod("android.net.Uri", "parse(java.lang.String)", "http://")); resolveInfo = callJavaMethod(callJavaMethod(getContext(), "android.content.Context", "getPackageManager()"), "android.content.pm.PackageManager", "resolveActivity(android.content.Intent, int)", browserIntent, getJavaStaticField("android.content.pm.PackageManager", "MATCH_DEFAULT_ONLY")); packageName = getJavaField(getJavaField(resolveInfo, "android.content.pm.ResolveInfo", "activityInfo"), "android.content.pm.ActivityInfo", "packageName");
Thank you once again...