简体   繁体   English

当我的应用程序打开并且用户选择“始终”在我的应用程序中打开域时,如何绕过Android意向过滤器?

[英]How do I bypass Android intent filter when my app is open and user has selected to “always” open domain in my app?

My app intercepts my entire website domain. 我的应用拦截了我的整个网站域。 However, I occasionally cannot support a particular page in app. 但是,有时我无法支持应用程序中的特定页面。 When this happens, I want to redirect the user back to the browser. 发生这种情况时,我想将用户重定向回浏览器。 Unfortunately, if the users has selected "Always" to open my app with this domain (rather than selecting "Only Once"), I get stuck in a redirect loop. 不幸的是,如果用户选择“始终”来使用该域打开我的应用程序(而不是选择“仅一次”),我将陷入重定向循环。

  1. Create a new intent with your url 用您的网址创建一个新的意图
  2. Create a second temporary intent with a generic http:// url 使用通用的http://网址创建第二个临时意图
  3. Get the default resolution for the temporary intent 获取临时意图的默认分辨率
  4. Set the original intent to the default resolution 将原始意图设置为默认分辨率
  5. Start the original intent 开始原始意图

      Intent intent = null; try { // #1 intent = new Intent(Intent.ActionView); intent.SetData(Android.Net.Uri.Parse(url)); // #2 Intent tempIntent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("http://")); // #3 var resolution = activity.PackageManager.ResolveActivity(tempIntent, Android.Content.PM.PackageInfoFlags.MatchDefaultOnly); // #4 intent.SetComponent(new ComponentName( resolution.ActivityInfo.ApplicationInfo.PackageName, resolution.ActivityInfo.Name)); // #5 StartActivity(intent); } catch { } 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:注册意图过滤器以使用我的应用程序打开电子邮件附件 - Android: Registering Intent Filter to open email attachment with my app 如何创建匹配自定义意图过滤器的文件以打开我的应用程序? - How create file to match custom intent filter to open my app? android:如何从我的应用程序打开另一个应用程序? - android: how do i open another app from my app? 如何在未打开“购买”对话框的情况下验证用户是否已在我的Android应用中完成购买? - How can I verify user has already done in purchase In my Android App without open Purchase Dialog? 在android测试中,当使用意图打开另一个应用程序时,如何返回到我的应用程序并继续以后的测试 - In android test, when use intent open another app, how to return to my app and continue later tests 如何使用户打开我的应用程序时Android键盘不会打开? - how do you make it so the Android keyboard doesnt open up when the user opens up my app? Android - 如何通过Intent在另一个应用程序中打开文件? - Android - How do I open a file in another app via Intent? 如何使用Android从Intent打开Paytm应用? - How do I open Paytm app from Intent using Android? 用户从我的应用程序注销时,始终打开android webview登录对话框 - Always open android webview Login dialog when user logged out from my app Android Intent-如何从选择列表中打开我自己的应用并获取我输入的消息 - Android intent - how to open my own app from choosing list and get the message I entered
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM