Skip to content

Instantly share code, notes, and snippets.

View brendanzagaeski's full-sized avatar

Brendan Zagaeski brendanzagaeski

  • Microsoft
  • Boston, MA, United States
View GitHub Profile
@brendanzagaeski
brendanzagaeski / FooFileActivity.cs
Last active November 25, 2023 22:07
Tell Android to open a particular file type in your Xamarin.Android app
using Android.App;
using Android.Content;
// Tell Android to open a particular file type in your Xamarin.Android app
// Different apps will produce different intents for the same file, so
// you will need multiple intent filters to handle all the cases.
// You can look in the `adb logcat` logs to see which intent appears
// after you have tapped on a file in an app.
@brendanzagaeski
brendanzagaeski / Metadata.xml
Last active December 7, 2021 14:22
Some Metadata.xml fixes for binding the Socialize Android SDK (http://getsocialize.com/sdk/) in Xamarin.Android
<metadata>
<!-- Some Metadata.xml fixes for binding the Socialize Android SDK (http://getsocialize.com/sdk/) in Xamarin.Android
Note that this is not a complete set of fixes. These changes only address the first round of compile errors. -->
<!-- Fixes for duplicate EventArgs, as discussed on:
http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/#Problem_Duplicate_custom_EventArgs_types
Error message: Error CS0102: The type `SomeClass` already contains a definition for `p0' (CS0102) -->
<attr path="/api/package[@name='com.socialize.auth.twitter']/interface[@name='TwitterAuthListener']/method[@name='onError' and count(parameter)=1 and parameter[1][@type='com.socialize.error.SocializeException']]" name="argsType">AuthTwitterErrorEventArgs</attr>
<attr path="/api/package[@name='com.socialize.facebook']/interface[@name='Facebook.DialogListener']/method[@name='onComplete' and count(parameter)=1 and parameter[1][@type='android.os.Bundle
@brendanzagaeski
brendanzagaeski / XamarinSubmitXcode.md
Created July 7, 2015 02:42
Steps to submit a Xamarin.iOS app using the Xcode Organizer

Note: these steps are for the special case where a user wishes to submit a Xamarin.iOS app to the App Store using the Xcode Organizer. In most cases the simpler option is instead to use Application Loader. See the first post on https://forums.xamarin.com/discussion/40388/disallowed-paths-itunesmetadata-plist-found-at-when-submitting-to-app-store/p1 for the simpler steps and additional information.

Steps to submit a Xamarin.iOS app using the Xcode Organizer

For this example assume that the name of the Xamarin.iOS project is "iPhoneApp1".

(Modified from the helpful post here.)

  1. Use the "Build -> Archive for Publishing" workflow in Xamarin Studio to create the .xcarchive (see also the "Building the Distributable" section on the publishing guide).
@brendanzagaeski
brendanzagaeski / Metadata.xml
Last active October 2, 2021 20:32
Some Metadata.xml fixes for binding NeoReaderSDK (http://www.neom.com/solutions/neoreader/SDK) in Xamarin.Android
<metadata>
<!-- Error CS0234: The type or namespace name `QuadCorners' does not exist in the namespace `DE.Neom.Neoreadersdk'. Are you missing an assembly reference?
This problem is caused by the default unspecified visibility of
the QuadCorners Java class.
Note in particular the very end of the following line from
`obj/Debug/api.xml`:
<class abstract="false" deprecated="not deprecated" extends="java.lang.Object" extends-generic-aware="java.lang.Object" final="false" name="QuadCorners" static="false" visibility="">
@brendanzagaeski
brendanzagaeski / Metadata.xml
Created December 22, 2015 23:44
Some Metadata.xml fixes for binding ADTECH Mobile (http://www.adtech.com/) in Xamarin.Android
<!-- This is an example of http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding-a-java-library/troubleshooting-bindings/#Problem_Duplicate_custom_EventArgs_types
In this particular case, the conflicting definition is in
`Com.Adtech.Mobilesdk.Publisher.Vast.Player.ILinearAdPlayer`.
That interface also defines an "onError" method.
Error CS0102: The type
`Com.Adtech.Mobilesdk.Publisher.Vast.Player.ErrorEventArgs'
already contains a definition for `p0' -->
<attr path="/api/package[@name='com.adtech.mobilesdk.publisher.vast.player']/interface[@name='VideoPlayerListener']/method[@name='onError' and count(parameter)=1 and parameter[1][@type='java.lang.Exception']]" name="argsType">VideoPlayerListenerOnErrorArgs</attr>
@brendanzagaeski
brendanzagaeski / gist:9337026
Last active April 18, 2020 10:27
Prevent the Xamarin.Android bindings generator from converting a get or set method to a property
# Prevent the Xamarin.Android bindings generator from converting a `get` or `set` method to a property
Xamarin.Android Java bindings projects will by default automatically bind any Java method that starts with "get" to be the getter of a C# property. To prevent this in specific cases, you can set the `propertyName` attribute of the method to the empty string. The same is true for methods that start with "set", except that they will only be converted to property setters if there is already a corresponding property getter. This requirement prevents the creation of set-only properties (see also http://msdn.microsoft.com/en-us/library/ms229006.aspx).
So for example, you would add something like the following to the Metadata.xml file:
```
<attr path="/api/package[@name='com.example.testandroidlib']/class[@name='MyClass']/method[@name='getNumberTen']" name="propertyName"></attr>
```
@brendanzagaeski
brendanzagaeski / Metadata.xml
Created May 20, 2014 02:33
Some Metadata.xml fixes for binding "Java WebSockets" (https://github.com/TooTallNate/Java-WebSocket/) in Xamarin.Android
<metadata>
<!-- Some Metadata.xml fixes for binding "Java WebSockets" (https://github.com/TooTallNate/Java-WebSocket/) in Xamarin.Android -->
<!-- This is a case of http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/#Problem_Duplicate_custom_EventArgs_types
Error CS0102: The type `Org.Java_websocket.WebsocketMessageEventArgs'
already contains a definition for `p0' -->
<attr path="/api/package[@name='org.java_websocket']/interface[@name='WebSocketListener']/method[@name='onWebsocketMessage' and count(parameter)=2 and parameter[1][@type='org.java_websocket.WebSocket'] and parameter[2][@type='java.nio.ByteBuffer']]" name="argsType">WebsocketMessageByteBufferEventArgs</attr>
@brendanzagaeski
brendanzagaeski / Metadata.xml
Created July 7, 2014 22:01
Some Metadata.xml fixes for binding the "Brother Print SDK for Android" (http://www.brother.com/product/dev/mobile/android/) in Xamarin.Android
<metadata>
<!-- Some Metadata.xml fixes for binding the "Brother Print SDK for
Android" (http://www.brother.com/product/dev/mobile/android/) in
Xamarin.Android. -->
<!-- Warning BG8401: Skipping Com.Brother.Ptouch.Sdk.LabelInfo.LabelColor, due to a duplicate field, method or nested type name
This one is a bit tricky. Let's first just try removing the whole
LabelColor nested class:
@brendanzagaeski
brendanzagaeski / gist:9417060
Last active January 8, 2019 09:25
NullReferenceException in ClientRuntimeChannel constructor on Xamarin.Android 4.12

To solve both of the problems from the stack traces below, follow these steps:

  1. Add the following to an XML file in the project:

    <?xml version="1.0" encoding="utf-8" ?>
    <linker>
    	<assembly fullname="System.ServiceModel">
    		<type fullname="System.ServiceModel.Channels.ChannelFactoryBase`1">
    
    
@brendanzagaeski
brendanzagaeski / gist:8602459
Created January 24, 2014 17:53
Some steps to try if Xamarin Studio says "Error updating Xcode project. Invalid parameter"
# Some steps to try if Xamarin Studio says "Error updating Xcode project. Invalid parameter"
1. Quit Xcode and Xamarin Studio.
2. Delete the `obj/` folder where Xamarin stores the generated Xcode files (or just the `obj/Xcode` folder, if you prefer)
3. Open the project in Xamarin Studio, and build the project.
4. Try to open the problematic XIB (or storyboard) file.