我正在使用Xamarin表单并为以下目标编写依赖服务:
打开iOS文件应用.(UIDocumentPickerViewController)
选择任何类型的文档.
将该文档复制到我的应用程序文档目录.(适用于应用访问)
通过将其路径存储到我的SQLite DB中,将该文档显示到我的应用程序中.
我在这里尝试做的是在条目点击上从我的应用程序调用Files应用程序并且click事件似乎运行良好我的依赖服务调用完美但现在当我尝试使用UIDocumentPickerViewController时我无法获取View控制器上下文在我的依赖服务中调用PresentViewController方法.现在我知道了xamarin表单的上下文,但我不知道它是否会在这里工作,我甚至不知道使用它是否是一个明智的想法,因为它已被标记为已过时,因为我不是来自iOS背景,我不知道什么是正确的解决方案.
我的代码如下:
public class DocumentPickerRenderer : IDocumentPicker
{
public object PickFile()
{
var docPicker = new UIDocumentPickerViewController(new string[] { UTType.Data, UTType.Content }, UIDocumentPickerMode.Import);
docPicker.WasCancelled += (sender, wasCancelledArgs) =>
{
};
docPicker.DidPickDocumentAtUrls += (object sender, UIDocumentPickedAtUrlsEventArgs e) =>
{
Console.WriteLine("url = {0}", e.Urls[0].AbsoluteString);
//bool success = await MoveFileToApp(didPickDocArgs.Url);
var success = true;
string filename = e.Urls[0].LastPathComponent;
string msg = success ? string.Format("Successfully imported file '{0}'", filename) : string.Format("Failed to import file '{0}'", filename);
var alertController …Run Code Online (Sandbox Code Playgroud) 我们最近决定更新我们在 google play 上发布 Beta 版的新应用程序,
现在阅读指南后,我想到了一些问题并想了解更多关于它们的信息,我用谷歌搜索以进一步了解找到了一些答案,但仍有一些我不确定的事情所以决定提出这个问题向上:
确保用户可以加入测试。您的测试人员需要拥有 Google 帐户 (@gmail.com) 或 G Suite 帐户才能加入测试。
在内部运行测试。使用内部测试轨道在几秒钟内将您的应用推送给多达 100 名内部测试人员。
一旦我发布了一个测试版应用程序并决定现在将其投入生产,它会作为不同的应用程序上传还是同样的,发布到测试版 Google Play 应用程序的评论是否会在我的生产应用程序上可见?(没有完全得到与此有关的任何信息。)
在其中一个要点中,它说我的应用程序在 beta 版本中应该具有比生产版本更高的版本代码,但是如果我在该版本中有更高的版本,它甚至不会是将被下载的应用程序什么时候它可能不是最稳定的版本?(这个真的让我很困惑)
检查您的 Android App Bundle 版本号。要使测试人员可以使用处于内部、封闭或开放测试轨道上的应用程序,它的版本代码必须高于您的生产版本。
为测试人员提供一个向您发送反馈的渠道。对于封闭式测试,让测试人员能够通过电子邮件、网站、消息论坛或其他合适的机制提供反馈。
我有一个Xamarin.Forms应用程序,其中使用 Autofac 进行 DI。
所以我想要的很简单,但我无法做一些看起来很容易做的事情。
所以我有一个类,它有两个构造函数,它们都有一个参数,并且根据某些条件我想解析其中一个。举个例子,我有一个类 A,我想要的是基于条件 B 或 C 应该得到解决。
例如:
public class A
{
public A(B bObject)
{...}
public A(C cObject)
{...}
}
Run Code Online (Sandbox Code Playgroud)
但我无法理解如何做到这一点。我尝试做如下的事情:
登记:
builder.RegisterType<A>().
UsingConstructor(typeof(C)).
Named<A>(nameof(C));
builder.RegisterType<A>().
UsingConstructor(typeof(B)).
Named<A>(nameof(B));
Run Code Online (Sandbox Code Playgroud)
解决:
DiContainer.ResolveNamed<A>(nameof(B));
DiContainer.ResolveNamed<A>(nameof(C));
Run Code Online (Sandbox Code Playgroud)
注:我已经在容器中注册了B和C,如下图:
builder.RegisterType<B>();
builder.RegisterType<C>()
Run Code Online (Sandbox Code Playgroud)
我对 AutoFac 有点陌生,我什至不确定这是否是正确的方法,我认为这与我注册两次有关,我不确定。
强烈感谢任何建议或帮助。
Jenkins 无法从 dl.google.com / maven.google.com 下载 xamarin 依赖项
下载失败原因:无法连接远程服务器
项目堆栈 Dotnet Xamarin Android 应用程序
错误
Downloading https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-core/16.0.1/firebase-core-16.0.1.aar to C:\Windows\system32\config\systemprofile\AppData\Local\XamarinBuildDownloadCache\googlefb-16.0.1/firebasecore.aar
C:\Windows\system32\config\systemprofile\.nuget\packages\xamarin.build.download\0.8.0\build\Xamarin.Build.Download.targets(52,3): error XBD001: Download failed. Please download https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-core/16.0.1/firebase-core-16.0.1.aar to a file called C:\Windows\system32\config\systemprofile\AppData\Local\XamarinBuildDownloadCache\googlefb-16.0.1/firebasecore.aar. [D:\myfolder\Jenkins\workspace\projectname\project\project.Android\project.Android.csproj]
Download failure reason: Unable to connect to the remote server
Downloading https://maven.google.com/com/crashlytics/sdk/android/crashlytics-core/2.6.3/crashlytics-core-2.6.3.aar to C:\Windows\system32\config\systemprofile\AppData\Local\XamarinBuildDownloadCache\crashlyticscore-2.6.3.aar
C:\Windows\system32\config\systemprofile\.nuget\packages\xamarin.build.download\0.8.0\build\Xamarin.Build.Download.targets(52,3): error XBD001: Download failed. Please download https://maven.google.com/com/crashlytics/sdk/android/crashlytics-core/2.6.3/crashlytics-core-2.6.3.aar to a file called C:\Windows\system32\config\systemprofile\AppData\Local\XamarinBuildDownloadCache\crashlyticscore-2.6.3.aar. [D:\myfolder\Jenkins\workspace\projectname\project\project.Android\project.Android.csproj]
Download failure reason: Unable to connect to the remote serverRun Code Online (Sandbox Code Playgroud)
我尝试过在 Jenkins 中配置企业代理。它在代理配置页面上工作,但在构建代码时抛出错误。请参阅下面的屏幕截图。

最近我更新到了最新版本的 .net MAUI,我有点惊讶地发现 MAUI 设备类现在已被标记为“过时”
我有多个用例,其中我将设备类用于某些用途。
例如,现在主线程方法已过时:
Device.BeginInvokeOnMainThread(() =>{});
Run Code Online (Sandbox Code Playgroud)
现在是否有一个新的助手类将执行这些活动,或者我错过了什么?
我正在尝试构建我的项目,但是当我这样做时,我收到此错误:"错误:包com.google.firebase.messaging不存在",以及其他4个相同类型的错误.
package md5f64326b4609986d97810cf2ced03c9ce;
public class MyFirebaseMessagingService
extends com.google.firebase.messaging.FirebaseMessagingService
implements
mono.android.IGCUserPeer
{
/** @hide */
public static final String __md_methods;
static {
__md_methods =
"n_onMessageReceived(Lcom/google/firebase/messaging/RemoteMessage;)V:GetOnMessageReceived_Lcom_google_firebase_messaging_RemoteMessage_Handler\n" +
"";
mono.android.Runtime.register ("FCMClient.MyFirebaseMessagingService, LimBands.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", MyFirebaseMessagingService.class, __md_methods);
}
public MyFirebaseMessagingService ()
{
super ();
if (getClass () == MyFirebaseMessagingService.class)
mono.android.TypeManager.Activate ("FCMClient.MyFirebaseMessagingService, LimBands.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "", this, new java.lang.Object[] { });
}
public void onMessageReceived (com.google.firebase.messaging.RemoteMessage p0)
{
n_onMessageReceived (p0);
}
private native void n_onMessageReceived (com.google.firebase.messaging.RemoteMessage p0);
private java.util.ArrayList refList;
public void monodroidAddReference …Run Code Online (Sandbox Code Playgroud) xamarin.android firebase xamarin xamarin.forms firebase-cloud-messaging
我足够新来使用Xamarin,在我的Xamarin Forms项目中创建了一个Master-Detail页面,并在ListView中表示了我想要放置Title和Icon的菜单,对于图标图像,我必须在所有设备项目中插入每个图标?
而且我还有一个小问题,当我单击菜单项并导航到选定的“详细信息”页面时,汉堡菜单消失了
MainPageMaster.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XXX"
Title="Master">
<StackLayout>
<ListView x:Name="MenuItemsListView"
SeparatorVisibility="None"
HasUnevenRows="true"
ItemsSource="{Binding MenuItems}">
<ListView.Header>
<Grid BackgroundColor="#03A9F4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="6"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="6"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="15"/>
<RowDefinition Height="30"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Label
Grid.Column="1"
Grid.Row="1"
Text="B1 Term"
HorizontalTextAlignment="Center"
Style="{DynamicResource SubtitleStyle}"/>
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout VerticalOptions="FillAndExpand"
Orientation="Horizontal"
Padding="20,10,0,10"
Spacing="20">
<Image Source="{Binding Icon}"
WidthRequest="40"
HeightRequest="40"
VerticalOptions="Center" />
<Label Text="{Binding Title}"
FontSize="Medium"
VerticalOptions="Center"
TextColor="Black"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
文件.cs …
所以我有一个要求,我的项目应该使用不同的 Android/iOS GoogleServices 文件,同时使用不同的配置,例如,当我使用调试配置时,它应该使用文件的调试版本,而在发行版中,它应该使用发行版版本。
类似于 Xamarin firebase 不同的 google-services,json 用于不同的构建配置
当我遵循已接受的答案时,我收到一个编译时错误:
该命令
COPY /Y "$(ProjectDir)GoogleServices\google-services-development.json" "$(ProjectDir)google-services.json"以代码 1 退出。
我尝试了 clean build 和 clean bin/obj 没有任何改变。
所以我尝试了这里提到的其他解决方案,结果是 GoogleServices 文件(所有这些文件)都被排除在项目之外,如果我构建并运行,什么也不会发生。我不确定这是否有效。
我在我的 csproj 中添加了以下几行,分别用于发布和调试
<ItemGroup Condition="'$(Configuration)'=='Debug'">
<GoogleServicesJson Include="Dev\google-services.json">
<Link>google-services.json</Link>
</GoogleServicesJson>
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Release'">
<GoogleServicesJson Include="Prod\google-services.json">
<Link>google-services.json</Link>
</GoogleServicesJson>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
其中 dev 和 prod 是我的本机 Android 项目中的根文件夹
欢迎任何建议。
visual-studio xamarin.ios xamarin.android xamarin xamarin.forms
所以我想做的很简单。
我正在nameof()某些基本类型上运行A ,因为我需要这些常量来满足特定需求。
但是当我尝试这样做时,例如nameof(bool)它说nameof()在当前上下文中不存在。
所有同义词似乎都是这样吗?
还有其他方法可以做到吗,还是我错过了一些东西。
我想做的是
public static readonly string BoolConstant= nameof(bool);
Run Code Online (Sandbox Code Playgroud)
预期结果:
BoolConstant= "bool";
Run Code Online (Sandbox Code Playgroud)
我将所有这些常数记下来吗?
我有一段使用 UIGraphics 方法的代码,似乎我使用的三种方法都已弃用。
这是一段 Xamarin.iOS 代码,但我相信 Swift 用户也可以在这里提供帮助,任何人都可以帮助我了解这些的新方法是什么,我正在尝试用 google 搜索,但我似乎没有得到任何信息关于这些方法的替代品的直接线索。
以下三种方法已被弃用;
UIGraphics.BeginImageContextWithOptions(size, false, ScreenDensity);
var image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
Run Code Online (Sandbox Code Playgroud)
完整的代码如下,不确定这是否有帮助......
private UIImage CreateBufferImage()
{
if (paths is null || paths.Count == 0)
{
return null;
}
var size = Bounds.Size;
UIGraphics.BeginImageContextWithOptions(size, false, ScreenDensity);
var context = UIGraphics.GetCurrentContext();
context.SetLineCap(CGLineCap.Round);
context.SetLineJoin(CGLineJoin.Round);
foreach (var path in paths)
{
context.SetStrokeColor(path.Color.CGColor);
context.SetLineWidth(path.Width);
context.AddPath(path.Path.CGPath);
context.StrokePath();
path.IsDirty = false;
}
var image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return image;
}
Run Code Online (Sandbox Code Playgroud)
谢谢