Tag: xamarin.android

Monodroid JNI for Javareflection调用私有方法

在Monodroid项目中,我需要能够在类上调用私有方法。 从相关问题的答案来看,似乎这可以通过反思在Java中实现: import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import android.os.ParcelFileDescriptor; … ParcelFileDescriptor pipe[] = null; try { Method createPipeMethod = ParcelFileDescriptor.class.getDeclaredMethod(“createPipe”); pipe = (ParcelFileDescriptor[]) createPipeMethod.invoke(null); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } 我需要使用Monodroid的代码。 不幸的是, java.lang.reflect在Monodroid中不可用 。 但是,有人建议我可以使用Monodroid项目中的JNI运行此代码。 Xamarin文档声明内联JNI是可能的 ,而不必绑定整个JAR。 […]

Android FFImageLoading使用URI(Xamarin)

我试图从光标加载联系人图像,所以我有每个图像的URI。 但是我想使用FFImageLoading库将这些图像添加到视图中,这样我就可以轻松加载占位符并进行圆形变换。 但是,我在使用带有URI的库时遇到了困难 – 我尝试使用Path将URI转换为url以使用LoadFromURL方法,但这种做法并不成功。 所以我想知道使用LoadImage或LoadStream方法是否更好,但我不确定如何最好地这样做。 这是我本来想要做的 // use FFImageLoading library to asynchronously: await ImageService .Instance .LoadUrl(item.PhotoURL, TimeSpan.FromHours(Settings.ImageCacheDurationHours)) // get the image from a URL .LoadingPlaceholder(“placeholderProfileImage.png”) // specify a placeholder image .Transform(new CircleTransformation()) // transform the image to a circle .Error(e => System.Diagnostics.Debug.WriteLine(e.Message)) .IntoAsync(viewHolder.ProfilePhotoImageView); 但是,对于我从联系人获得的图像,我有一个Uri,我可以使用以下内容加载它,但我无法对其进行转换: var contactUri = ContentUris.WithAppendedId(ContactsContract.Contacts.ContentUri, Contacts[position].LongId); var contactPhotoUri = Android.Net.Uri.WithAppendedPath(contactUri, Android.Provider.Contacts.Photos.ContentDirectory); […]

如何使用Visual Studio / Xamarin Studio绑定Xamarin中的* .AAR文件

我想绑定Xamarin中的HoloEverywhere。 HoloEverywhere二进制文件是.aar文件。 似乎如果我将其标记为InputJar,Java库绑定项目中没有任何反应。 那么有没有办法让它发挥作用?

如何在Android应用程序中调用Mono for Android类?

我在Mono for Android项目中创建了一个相当简单的Activity: [Activity(Label = “AndroidApplication1”, MainLauncher = true, Icon = “@drawable/icon”)] public class Activity1 : Activity { private string value = “intitial”; [Export] public string GetString() { return value; } [Export] public void SetString(string newValue) { value = newValue; } } 该活动应仅作为概念validation,因此其简单性。 现在,我希望能够从“普通的”基于Java的Android应用程序调用方法GetString()。 在Xamarin的文档中 ,我已经阅读了Java to Managed interop,这似乎正是我正在寻找的。 如果我理解正确,当Mono for Android应用程序编译时,它会生成称为Android Callable Wrappers(ACW)的Java类。 然后我应该能够从基于Java的Android应用程序调用这些ACW上的方法。 […]

在Xamarin.Android中加载.so文件

我正在尝试在Xamarin.Android中将Java类转换为C#。 原始的Java类有这个: private native boolean OpenDeviceCtx(Object obj); public native boolean CloseDevice(); public native boolean GetDiodesStatus(byte[] bArr); public native boolean GetFrame(byte[] bArr); public native boolean GetImage(int i, byte[] bArr); public native boolean GetImage2(int i, byte[] bArr); public native boolean GetImageByVariableDose(int i, byte[] bArr); public native boolean GetImageSize(); public native boolean GetInterfaces(byte[] bArr); public native String GetVersionInfo(); […]

Java到C#:在Generic中扩展

我试图将这个Java(Android)代码转换为c#(MonoDroid),但我不明白 public class BalloonOverlayView extends FrameLayout

如何调试:应用程序中的JNI DETECTED ERROR:使用无效的jobject

我正在开发一个Xamarin Android项目,我收到以下错误( 这里有完整的日志) 11-07 08:28:09.067: A/art(7164): art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0xd4fd90e0 11-07 08:28:09.067: A/art(7164): art/runtime/java_vm_ext.cc:410] “Thread-1973″ prio=10 tid=26 Runnable 11-07 08:28:09.067: A/art(7164): art/runtime/java_vm_ext.cc:410] | group=”main” sCount=0 dsCount=0 obj=0x137270a0 self=0xc89d4900 11-07 08:28:09.067: A/art(7164): art/runtime/java_vm_ext.cc:410] | sysTid=9034 nice=-11 cgrp=default sched=0/0 handle=0xd4b3a930 11-07 08:28:09.067: A/art(7164): art/runtime/java_vm_ext.cc:410] | state=R schedstat=( 310795035 15833156 94 […]

从Java代码使用C#库和Mono for Android?

有可能从Java代码使用带有Mono for Android的C#库吗? 可以使用mtouch命令中的“–xcode”标志从Objective-C到C#(MonoTouch)执行此操作。 但是Mono for Android有一个等价的东西吗? 有理由这样做吗? 谢谢! Gwennin

Xamarin VS2015设计师无法正常工作

我正在使用xamarin for visual studio 2015.两天后,布局的设计师停止了工作。 很难确定问题因为我不记得在这些日子里做了什么具体的事情。 以下是错误消息的屏幕截图 我一直在努力遵循网络上的指示,包括xamarin建议,但没有任何成功。 以下是例外的详细文本: java.lang.NoClassDefFoundError: com/android/utils/ILogger at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.privateGetMethodRecursive(Class.java:3048) at java.lang.Class.getMethod0(Class.java:3018) at java.lang.Class.getMethod(Class.java:1784) at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526) Caused by: java.lang.ClassNotFoundException: com.android.utils.ILogger at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) … 7 more Error: A JNI error has occurred, please check your installation and try again Java […]

如何同步两个Listview位置

我有两个ListViews 。 当我滚动任何一个列表时,有没有办法同步ListViews的位置。 我实现了一个AbsListView.OnScrollListener ,注册到ListView 。 滚动ListView ,将触发OnScrollListener的onScroll()方法,然后调用`smoothScrollToPosition()’。 但它确实正常工作。 有人可以为我提供任何代码示例吗?