小编Ram*_*say的帖子

AndroidGameWindow.SetDisplayOrientation NullReferenceException

我使用MonoGame和Xamarin为Android开发了一款游戏.我将BugSense合并到其中并迅速开始获得以下异常堆栈跟踪:

System.NullReferenceException: Object reference not set to an instance of an object
at Microsoft.Xna.Framework.AndroidGameWindow.SetDisplayOrientation (Microsoft.Xna.Framework.DisplayOrientation) <0x001c4>
at Microsoft.Xna.Framework.AndroidGameWindow.SetOrientation (Microsoft.Xna.Framework.DisplayOrientation,bool) <0x00097>
at Microsoft.Xna.Framework.OrientationListener.OnOrientationChanged (int) <0x001c7>
at Android.Views.OrientationEventListener.n_OnOrientationChanged_I (intptr,intptr,int) <0x0003f>
at (wrapper dynamic-method) object.ed9d7c7c-f3e6-4d7a-9249-1a139a251aed (intptr,intptr,int) <0x00043>
Run Code Online (Sandbox Code Playgroud)

这就是我的活动设置方式:

[Activity(Label = "My Cool Game"
        , MainLauncher = true
        , Icon = "@drawable/icon"
        , Theme = "@style/Theme.Splash"
        , AlwaysRetainTaskState = true
        , LaunchMode = Android.Content.PM.LaunchMode.SingleTask
        , ScreenOrientation = ScreenOrientation.Portrait
        , ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden)]
Run Code Online (Sandbox Code Playgroud)

在游戏构造函数中,我有以下内容:

public Game1()
{
    _graphics = new GraphicsDeviceManager(this); …
Run Code Online (Sandbox Code Playgroud)

c# android xamarin.android monogame

17
推荐指数
1
解决办法
318
查看次数

在APK中保护字符串

我正在使用Xamarin的Mono for Android开发Android应用程序.我目前正在使用Google Play API添加应用内购买功能.为此,我需要从我的应用程序中向Google发送公共许可证密钥.关于此问题,Google建议如下:

安全建议:强烈建议您不要对Google Play提供的确切公共许可证密钥字符串值进行硬编码.相反,您可以在运行时从子字符串构造整个公共许可证密钥字符串,或者在将其传递给构造函数之前从加密存储中检索它.这种方法使恶意第三方更难以修改APK文件中的公共许可证密钥字符串.

我从未处理过加密,黑客攻击/破解或软件安全的任何其他方面,因此我不确定如何实施Google的建议.我的问题是如何在没有安全专家的情况下如何充分保护使用Mono for Android制作的Android APK中的字符串?

c# security android xamarin.android xamarin

5
推荐指数
1
解决办法
1254
查看次数

找不到与common_signin_btn_icon_dark.xml中的给定名称匹配的资源

我正在使用VS2012中的Xamarin Android为Android开发MonoGame应用程序(C#).一切都进展顺利然后在特定的构建中我突然开始得到4个类似的错误,没有明显的原因.这些错误都源自Xamarin组件商店中的Google Play组件:

No resource found that matches the given name (at 'drawable' with value '@drawable/common_signin_btn_icon_disabled_focus_dark').
No resource found that matches the given name (at 'drawable' with value '@drawable/common_signin_btn_icon_disabled_focus_light').
No resource found that matches the given name (at 'drawable' with value '@drawable/common_signin_btn_text_disabled_focus_dark').
No resource found that matches the given name (at 'drawable' with value '@drawable/common_signin_btn_text_disabled_focus_light').
Run Code Online (Sandbox Code Playgroud)

这些都发生在

组件\ googleplayservicesgingerbread-16.0.0.1\LIB\Android版\ 16 \内容\谷歌播放服务\ libproject \的Google Play-services_lib \水库\绘制\ common_signin_btn_text_light.xml

在我使用这个组件一段时间之后,我不确定是什么触发了这些错误突然弹出.我也不知道如何摆脱它们.

我的项目使用Android版本2.3,API级别10进行编译.最小目标也是v2.3 API级别10,目标版本设置为v4.4 API 19.

c# android monogame xamarin google-play-services

5
推荐指数
1
解决办法
3382
查看次数

不推荐使用文本选择控件,改为用户 contextMenuBuilder

我已经实现了一个自定义文本选择控件,以在突出显示的文本上的默认复制/粘贴/selectAll 旁边添加一个打开地图按钮,如下所示:

class MapTextSelectionControls extends MaterialTextSelectionControls {
  // Padding between the toolbar and the anchor.
  static const double _toolbarContentDistanceBelow = 20.0;
  static const double _toolbarContentDistance = 8.0;

  MapTextSelectionControls();

  @override
  Widget buildToolbar(
      BuildContext context,
      Rect globalEditableRegion,
      double textLineHeight,
      Offset selectionMidpoint,
      List<TextSelectionPoint> endpoints,
      TextSelectionDelegate delegate,
      ClipboardStatusNotifier? clipboardStatus,
      Offset? lastSecondaryTapDownPosition,
      ) {
    //.. some code here

    return MapSelectionToolbar(
      anchorAbove: anchorAbove,
      anchorBelow: anchorBelow,
      clipboardStatus: clipboardStatus,
      handleCopy: canCopy(delegate)
          ? () => handleCopy(delegate, clipboardStatus)
          : null,
      handleMap: selectedText.isNotEmpty
          ? () {
        openLink(generateLocationLinkFromQuery(selectedText));
        delegate.hideToolbar();
      }
          : null, …
Run Code Online (Sandbox Code Playgroud)

flutter

5
推荐指数
1
解决办法
2286
查看次数

将.Net int数组转换为Java.Lang.Object

我正在使用Xamarin将我的WP8应用程序移植到Android.我使用Parse作为数据后端.我得到了一些我希望保存到Parse中的整数.Parse的API有一个只接受Java.Lang.Object的Put()方法.我不知道如何将我的.Net int数组转换为Java.Lang.Object.

c# mono xamarin.android parse-platform xamarin

1
推荐指数
1
解决办法
2030
查看次数