android-safe-args 相关问题


活动深层链接 - IllegalArgumentException:缺少必需的参数并且没有 android:defaultValue

在我的应用程序中,我有以下结构: 在我的应用程序中,我具有以下结构: <!-- AndroidManifest.xml --> <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application> <activity android:name=".DeepLinkActivity" android:exported="true" android:launchMode="singleInstancePerTask"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="myhost" android:path="/mypath" android:scheme="myscheme" /> </intent-filter> </activity> </application> </manifest> <!-- activity_deep_link.xml --> <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.fragment.app.FragmentContainerView android:id="@+id/navHostFragment" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" app:defaultNavHost="true" tools:navGraph="@navigation/my_nav_graph" /> </FrameLayout> // DeepLinkActivity.kt class DeepLinkActivity : AppCompatActivity() { private lateinit var binding: ActivityDeepLinkBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityDeepLinkBinding.inflate(layoutInflater) setContentView(binding.root) setUpNavigationGraph() } private fun setUpNavigationGraph() { val navHostFragment = supportFragmentManager .findFragmentById(binding.navHostFragment.id) as NavHostFragment val navController = navHostFragment.navController val navGraph = navController.navInflater .inflate(R.navigation.my_nav_graph) .apply { this.setStartDestination(R.id.notTheStartDestinationFragment) } val startDestinationArgs = bundleOf( "someRequiredArgumentHere" to false ) navController.setGraph(navGraph, startDestinationArgs) } } 当我通过 ADB (adb shell am start -d myscheme://myhost/mypath) 通过深度链接打开该活动时,该活动正常启动。 但是当我通过 Chrome 应用程序启动它时,应用程序崩溃了: 原因:java.lang.IllegalArgumentException:缺少必需参数“someRequiredArgumentHere”并且没有 android:defaultValue 观察:我正在使用 Safe Args 插件。 我做错了什么以及为什么行为不同? 我刚刚发现为什么在通过浏览器导航时会忽略 startDestinationArgs。 如果我们检查NavController#setGraph(NavGraph, Bundle?)的内部代码,如果没有发生深层链接,NavController#onGraphCreated(Bundle?)只会使用startDestinationArgs。 作为一种解决方法,在设置导航图之前,我只需清除活动的意图(但这可能不是解决该问题的最佳方法)


为什么 get_posts() 有效但 WP_Query( $args ) 无效?

我有以下 WordPress 代码片段: $args = 数组( 'posts_per_page' => 1, // 为了安全,设置返回值为1条记录 'post_type' => 'fs_ski_resorts', '


第一个功能到底是如何工作的?

刚刚开始我的编码之旅,不知道为什么这个功能有效: 导入数学 def 乘法(*args): 参数 = int(参数[0]) arg_length = len(str(abs(args))) 返回参数 * (5 ** arg_lengt...


.NET MAUI:自定义Shell TitleView并绑定到当前页面标题

我想用我自己的自定义布局替换默认的 Shell 标头,如下所示: 我想用我自己的自定义布局替换默认的 Shell 标头,如下所示: <?xml version="1.0" encoding="UTF-8" ?> <Shell x:Class="MyNamespace.App.AppShell" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MyNamespace.App" xmlns:pages="clr-namespace:MyNamespace.App.Pages" BindingContext="{x:Static local:MainView.Instance}" Shell.FlyoutBehavior="{Binding ShellFlyoutType}" x:Name="shellMain"> <Shell.TitleView> <Grid ColumnDefinitions="*,200"> <Label BindingContext="{x:Reference shellMain}" Text="{Binding Path=CurrentPage.Title, Mode=OneWay}" FontSize="Large" TextColor="White" /> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="Orange" Grid.Column="1" HorizontalOptions="End" /> </Grid> </Shell.TitleView> <ShellContent Title=" Login" ContentTemplate="{DataTemplate local:MainPage}" Route="login" FlyoutItemIsVisible="False" /> <ShellContent Title="Dashboard" ContentTemplate="{DataTemplate pages:DashboardPage}" Route="dashboard" /> </Shell> 我无法绑定当前页面标题。 我的 AppShell.xaml Shell 声明如下 <Shell ... x:Name="shellMain"> 作为替代方案,您可以在 OnNaviged 方法中设置 titleview : 在 AppShell.xaml 中,定义标签的名称 <Shell.TitleView> <Grid ColumnDefinitions="*,200"> <Label BindingContext="{x:Reference shellMain}" x:Name="mylabel" FontSize="Large" TextColor="White" /> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="Orange" Grid.Column="1" HorizontalOptions="End" /> </Grid> </Shell.TitleView> 在AppShell.xaml.cs中,重写OnNaviged方法,获取当前项目 protected override void OnNavigated(ShellNavigatedEventArgs args) { base.OnNavigated(args); var shellItem = Shell.Current?.CurrentItem; string title = shellItem?.Title; int iterationCount = 0; while (shellItem != null && title == null) { title = shellItem.Title; shellItem = shellItem.CurrentItem; if (iterationCount > 10) break; // max nesting reached iterationCount++; } myLabel.Text = title; } 希望它对你有用。 我正在尝试同样的方法来修改 TitleView 的外观。它可以在 iOS 上运行,尽管那里还有另一个错误。但在 Android 上我遇到了同样的问题。在前进导航中,它会更新标题,但当您按后退按钮时,标题不会更新。我已经打开了一个问题并添加了一个存储库。 https://github.com/dotnet/maui/issues/12416#issuecomment-1372627514 还有其他方法可以修改TitleView的外观吗? 我使用视图模型开发了这个解决方法,主要不是为了提供 MVVM 解决方案,而是因为其他建议的答案对我不起作用。 (我怀疑 Liqun Shen 2 月 15 日针对他自己的问题的评论中的建议会起作用。但我没有注意到这一点,直到我自己修复)。 当前页面的标题保存在可由 shell 的视图模型和每个内容页面的视图模型访问的类中: public class ServiceHelper { private static ServiceHelper? _default; public static ServiceHelper Default => _default ??= new ServiceHelper(); internal string CurrentPageTitle { get; set; } = string.Empty; } shell 中每个内容页面的视图模型提供其页面标题。为了促进这一点,大部分工作都是由基本视图模型完成的,它们都是从该模型派生而来的: public abstract class ViewModelBase(string title) : ObservableObject { private ServiceHelper? _serviceHelper; public string Title { get; } = title; internal ServiceHelper ServiceHelper { get => _serviceHelper ??= ServiceHelper.Default; set => _serviceHelper = value; // For unit testing. } public virtual void OnAppearing() { ServiceHelper.CurrentPageTitle = Title; } } 每个 shell 内容页面视图模型只需要让其基础视图模型知道它的标题: public class LocationsViewModel : ViewModelBase { public LocationsViewModel() : base("Locations") { } } 每个 shell 内容页面都需要在其视图模型中触发所需的事件响应方法: public partial class LocationsPage : ContentPage { private LocationsViewModel? _viewModel; public LocationsPage() { InitializeComponent(); } private LocationsViewModel ViewModel => _viewModel ??= (LocationsViewModel)BindingContext; protected override void OnAppearing() { base.OnAppearing(); ViewModel.OnAppearing(); } } Shell 的视图模型为标题栏提供当前页面的标题: public class AppShellViewModel() : ViewModelBase(Global.ApplicationTitle) { private string _currentPageTitle = string.Empty; public string CurrentPageTitle { get => _currentPageTitle; set { _currentPageTitle = value; OnPropertyChanged(); } } public void OnNavigated() { CurrentPageTitle = ServiceHelper.CurrentPageTitle; } } Shell 需要在其视图模型中触发所需的事件响应方法: public partial class AppShell : Shell { private AppShellViewModel? _viewModel; public AppShell() { InitializeComponent(); } private AppShellViewModel ViewModel => _viewModel ??= (AppShellViewModel)BindingContext; protected override void OnNavigated(ShellNavigatedEventArgs args) { base.OnNavigated(args); ViewModel.OnNavigated(); } } 最后,Shell 的 XAML 在标题栏/导航栏上显示由 Shell 视图模型提供的当前页面的标题: <Shell.TitleView> <HorizontalStackLayout VerticalOptions="Fill"> <Image Source="falcon_svg_repo_com.png" HeightRequest="50"/> <Label x:Name="CurrentPageTitleLabel" Text="{Binding CurrentPageTitle}" FontSize="24" Margin="10,0" VerticalTextAlignment="Center"/> </HorizontalStackLayout> </Shell.TitleView>


ArrayList.add:它是如何工作的?

我创建了这个小程序.. 公共静态无效主(字符串[] args){ Person P = new Person("will", "Deverson", "15/06/1987", "Bonifico"); 产品 PC = 新产品("Asus VivoBook", "AVB2...


Long 不能转换为 String

我想知道为什么在以下代码中出现以下异常: 公开课 AAA { 公共静态无效主(字符串[] args)抛出ParseException{ AAA a = 新 AAA(); ...


为什么要在Java中使用void?

我是 Java 新手,我问自己为什么要使用 void 关键字,例如: 公共静态无效主(字符串[] args){ System.out.println("你好,世界!"); } 如果 void 关键字...


Python 中带有参数的类装饰器,引发 TypeError:缺少 1 个必需的位置参数:'type'

以下代码: def myDecorator(cls, 类型): 类包装器(cls): contaVarClasse = 0 def __init__(cls, *args, **kwargs): 以 cls 为单位的值。


无法在每个交易的链代码中设置多个事件,仅获取最后一个事件

我在链代码(Hyperledger Fabric v1.1)的函数中应用了多个事件。 func (t *SimpleChaincode) initUsers(stub shim.ChaincodeStubInterface, args []string) pb.Response { ... //事件


Django-channels 实例关闭时间过长而被杀死

谁能告诉我可能是什么问题? 警告应用程序实例 谁能告诉我可能是什么问题? 警告应用程序实例 wait_for=> 连接 关闭时间过长并被终止。 我的阿斯吉 "^subscription", channels_jwt_middleware(MyConsumer.as_asgi(schema=schema)) ) application = ProtocolTypeRouter({ "http": django_asgi_app, "websocket": QueryAuthMiddleware( URLRouter([ subscription_url, ]) ), })``` my custom MyConsumer ```class MyConsumer(GraphQLWSConsumer): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.profile_id = None async def __call__(self, scope, receive, send): user = scope.get("user", None) time_zone = await get_current_timezone(user) self.profile_id = scope.get("active_profile_id", None) self.timezone = time_zone if time_zone else settings.TIME_ZONE await super().__call__(scope, receive, send) async def connect(self): await super().connect() await change_status(True, self.profile_id) async def disconnect(self, close_code, *args, **kwargs): await super().disconnect(close_code) await change_status(False, self.profile_id)``` 解决我的问题 daphne -b 0.0.0.0 -p $SERVER_PORT --application-close-timeout 60 --proxy-headers server.asgi:application


为什么较大的 Xss 不能提供更大的最大堆栈深度?

首先,代码: 公共类 StackSOF { 私有 int 深度 = 0; 公共无效堆栈泄漏(){ 深++; 堆栈泄漏(); } 公共静态无效主(字符串[] args){


在 Stripe 结帐会话中集成自定义税费和折扣

您能帮我将税收和折扣整合到我的 Stripe sission 中吗 这是我当前的代码 类 CreateCheckoutSessionOrderView(视图): def get(自身, 请求, *args, **kwargs): 或者...


如何通过多个元键进行排序?

我使用自定义循环在页面上显示我的事件,我使用以下命令按事件开始日期进行精细排序: $args = 数组( 'post_type' => '事件', '订单' => 'ASC', '


使用递归创建单行号模式

编写一个打印出数字序列的递归方法。 printSequence(4) 打印 1 2 3 4 3 2 1 公开课练习{ 公共静态无效主(字符串[] args){ 打印序列(4); ...


我如何制作对象容器以及如何在其他文件中使用它

我的主类中基本上有一个数组列表 公共静态无效主(字符串[] args){ 列表场景Li = new ArrayList(); 字符串a=“”; escenariosLi.add(0,...


如何为Android Pay添加假信用卡Visa?

我正在开发一个Android应用程序,它使用android pay进行付款。在 https://codelabs.developers.google.com/codelabs/android-pay/#13 网站中。这是网站上写的


在线程中渲染时窗口内容混乱

所以,当我像这样运行我的程序时,弹出的窗口很好,带有我之前附加的PNG图像: 无效渲染(窗口* w){ w->渲染(); } int main(int argc, char** args){ &...


在 Android 14 中启用输入法时出错 - ANDROID

在 Android 中,启用输入之前工作正常,但当我在 Android 14(sdk 34)中测试时,出现以下异常。 致命异常:java.lang.SecurityException:设置键:<


如何使用内部库 Enum 进行 Clap Args

我目前正在开发一个安全工具的 Rust 端口。与 Rust 的指南一致,我想将核心库隔离到自己的包中,以便我们可以创建各种工具(CLI、API、流......


在 Bash 中解析命令行参数的最佳方法?

经过几天的研究,我仍然无法找出解析 .sh 脚本中的 cmdline args 的最佳方法。根据我的参考资料, getopts cmd 是可行的方法,因为它“提取并


Android Studio:导入库的奇怪问题

我正在尝试使用 Android Studio (gradle 8) 和公共 github 库:AndroidUSBCamera 创建一个 Android 应用程序。 我不认为我面临与库相关的问题,而是依赖/gradle/android


'。'宏参数列表中出现意外,在`#define error(args...)`中

我在 C++ 中使用这个定义来调试我的变量,它在 clion 和 codeblocks 中工作,但在 Visual Studio 22 中不起作用。 错误 C2010 '.':宏参数列表 codeforces 中出现意外 文件名是&


Android Studio 中选择一行代码的快捷方式

android studio中有选择一行代码的捷径吗?


扫描字符串文字 common.gypi 时安装 npm 包时出错 -- node-gyp EOL

我正在使用 npm i 提取 React 应用程序的依赖项,我得到: gyp 信息 spawn args 'build', npm 错误! gyp 信息生成参数 '-Goutput_dir=.' npm 错误! gyp 信息生成参数] npm 错误!追溯(最...


Nodemon 不再工作了。用法:nodemon [nodemon 选项] [script.js] [args]

nodemon 一直为我工作。我总是使用nodemon服务器,它将运行服务器文件并监视更新,然后节点将重新启动。但现在当我这样做时,我在cmd中得到了这个(我使用windows):


Android 无法请求 Android 13 设备的存储权限

在我的Android项目中,我要求用户打开相机。除此之外,我还要求获得存储许可。该权限适用于 Android 版本 12 及以下版本,但适用于...


MAUI 中切换风格问题

我正在我的 MAUI 项目上使用开关。我在 Android 设备 10 和 11 上发现了样式问题,但在 Android 12 上,不存在样式问题。 以下是 Android 10 和 Android 11 的屏幕截图。 贝尔...


在 Android Studio 可组合项中使用滑块

我正在尝试使用 Android Studio 编写一个 Android 应用程序。 看来最新的 android studio 只支持 Kotlin。 我想要一个函数来生成一个滑块,该滑块的起始值介于...


如何在 Android for Cars Android Auto 中向行添加操作?

我想在 Android Auto 的汽车应用程序 Android 中显示一个列表。该列表应包含带有两个按钮的项目,用于单独的操作。 我尝试添加 addAction(),但似乎没有用...


当我尝试“将项目与 gradle 文件同步”时,会弹出警告

警告:将新的 ns schemas.android.com/repository/android/common/02 映射到旧的 ns schemas.android.com/repository/android/common/01 警告:映射新的 ns schemas.android.com/repository/android/ge...


Android Studio 未检测到移动设备

我正在运行Android Studio Flamingo版本。我的 Samsung M32 已连接用于调试应用程序,但 Android Studio 未检测到它。运行“故障排除设备”时


启动应用程序时出现 Android INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION

我是Android开发新手,这是我第一次尝试。当尝试运行 android studio 创建的模板项目时,我看到以下错误。 未能完成会话:


C# 上的 android 电报

有人有一个用 C# 编写的可以在 android 上运行的简单电报客户端示例吗? 我找到了简单的android java示例:https://github.com/androidmads/TelegramBotSample 我发现很简单...


Android Studio 由于“内部错误”而无法打开

`内部错误。请参考https://code.google.com/p/android/issues java.lang.AssertionError:无法读取/Users/arnavgupta/Library/Application Support/Google/AndroidStudio2023.1/


Buildozer 无法将 Kivy 应用程序编译到 android

我在 VirtualBox 中使用 Ubuntu Desktop 22.04.3。我正在尝试使用 Kivy 为 android 制作 AR/VR 程序,但是当我在终端中运行命令:buildozer android debug 时。我收到一个关于


maui android 应用程序在管道中构建失败,并出现错误“找不到 Android SDK 目录”

如果没有任何代码更改,Android 的管道构建将失败并出现以下错误。 /opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/33.0.95/tools/Xamarin.Android.Tooling.targets(70...


如何反编译kotlin android apk?

我有自己用 kotlin 开发的 Android 应用程序。在我使用下面的 adb 命令从物理 Android 设备中提取我的 apk 后,我丢失了所有源代码(硬盘崩溃) - c:\> adb shell pm...


在 Gradle Bar 中找不到 SHA-1 指纹密钥的签名报告:Android Studio Hedgehog

这是我在Android Studio中的GradleBar(版本:hedgehog) 我想从 Android Studio for Firebase 获取 SHA-1 密钥指纹。 我想要在我的 gradle 栏中签名报告文件的示例 ->


自 Android 13 起无法启动任意 Activity

我构建了一个小型个人应用程序,它允许我为不同的 URL 指定不同的浏览器。在 Android 13 之前,它运行良好,但在 Android 13 之后的某个时候,它开始失败......


将android studio更新到hedgehog版本后manifest文件出现错误

我正在开发一个运行良好的 Android 应用程序,但当我将 Android Studio 更新到最新版本(即 Hedgehog 2023)时,我开始在清单文件中收到一堆错误。 明显...


自 Android Studio 4.1 起,Android 后台 Drawable 无法在按钮中工作

我发现从 Android Studio 4.1 开始,我无法通过在其 android:background 上设置颜色来更改 Button 的背景颜色,只是没有效果。并且自定义 Drawable 也无法正常工作。 我的


属性 application@label 也存在于

在我的android项目中安装新库后,出现以下错误: /android/app/src/debug/AndroidManifest.xml 错误: 属性应用@标签值=(同情心)来自(未知) ...


即使在 Appium 2 中使用 driver.close() 或 driver.quit() 与 UiAutomator2 驱动程序后,Android 应用程序也不会关闭

即使在 Appium 2 中使用 driver.close() 或 driver.quit() 与 UiAutomator2 驱动程序后,Android 应用程序也不会关闭 使用 W3C 获取 Android 所需的功能 返回新的 UiAutomator2Options()...


如何在flutter中查看android和web平台的html文件?

我正在创建一个可以在 android 和 web 平台上运行的 flutter 项目。 我在网络平台上查看 html 时遇到问题。 我使用了一个插件 webview_flutter 在 android 平台上查看 html 但是......


找不到 com.appnext.sdk:ads:2.7.1.473

为了测试 Yandex Ad SDK,我在 Android Studio 中创建了一个新项目 根据他们的文档,我将以下存储库添加到 settings.gradle 中: maven { url“https://android-sdk.is.com/”...


Android Compose 基础知识 - 项目:创建名片应用程序

在此处输入图像描述当前正在完成此练习 https://developer.android.com/codelabs/basic-android-kotlin-compose-business-card?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%


更改基于设备Android Studio的位图大小[已关闭]

在android studio中该函数的返回值 BitmapFactory.decodeResource(getResources(), R.drawable.basictiles) 根据设备大小而变化。 像素: 大小 = 1.792.000 高度、宽度=1120,400...


Flutter Android Studio 未在新项目上显示 Flutter 应用程序

我已经在我的Windows 11笔记本电脑上成功安装了ANdroid Studio和Flutter。当我启动 Android Studio 并选择“新 Flutter 应用程序”时,它向我展示了这一点。谁能告诉我为什么。以及如何...


无法构建或发布应用程序 maui,有很多错误

我的应用程序在启动时在 IOS 和 Android 上运行良好,但是当我尝试在 Android 上发布应用程序时,我收到所有这些错误: android 应用程序 .net maui 1>C:\Program Files\Microsoft Visual Studio�2\


如何从 Tizen Web 应用程序启动配套的 Android 应用程序?

我正在开发一个 Tizen Web 应用程序,它在 Android 设备上有一个配套应用程序。 我正在尝试从 Tizen Web 应用程序启动 Android 应用程序,但我不确定为什么它没有启动...


© www.soinside.com 2019 - 2024. All rights reserved.