Re: [mono-android] Android compatibility pack

2012-03-10 Thread Hani Gobran
Hi Jon,

 

When is the 4.2 scheduled for release?

 

-Hani

 

From: monodroid-boun...@lists.ximian.com 
[mailto:monodroid-boun...@lists.ximian.com] On Behalf Of Piotr Kryger
Sent: Wednesday, March 07, 2012 11:35 PM
To: Discussions related to Mono for Android
Subject: Re: [mono-android] Android compatibility pack

 

Bump

W dniu 5 marca 2012 07:52 użytkownik Piotr Kryger  
napisał:

Thanks for the explanation.

What is the EAT for compatibility pack bindings?

 

Piotr

W dniu 2 marca 2012 23:29 użytkownik Jonathan Pryor  napisał:

 

On Mar 2, 2012, at 4:44 PM, Piotr Kryger wrote:
> In M4A , AFAIK, it won't be possible since there is no way to inherit java 
> types defined in third party jar (or maybe there is a way?).

There is a way, it's just very painful. Proper docs haven't been published, but 
there is a sample that shows manual binding:

   
https://github.com/xamarin/monodroid-samples/blob/master/SanityTests/Adder.java
   
https://github.com/xamarin/monodroid-samples/blob/master/SanityTests/ManagedAdder.cs

The upcoming 4.2 series will include tooling to automate much of the binding 
drudgery; if possible, I'd suggest waiting. The 4.2 release will also contain 
bindings for the compatibility libraries.

 - Jon

___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

 

 

  _  

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1913 / Virus Database: 2114/4857 - Release Date: 03/07/12

___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Android compatibility pack

2012-03-10 Thread Jonathan Pryor
On Mar 10, 2012, at 10:44 AM, Hani Gobran wrote:
> When is the 4.2 scheduled for release?

When we get our ducks in a row ^H^H^H^H^H^H^H as soon as practical. :-)

 - Jon

___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


[mono-android] Urban Airship Push Notifications - JNIENV

2012-03-10 Thread GavinBryan
I'm writing some Mono For Android code to use Urban Airship Push
Notifications (www.http://urbanairship.com). I have downloaded the Urban
Airship sample java android project and can get everything working using
their Java project but need to create a Mono For Android project and make
some calls to their JAR file (urbanairship-lib-1.0.7.jar) which I have
included in my project and seem to be able to access the Java classes and
methods using JNIENV, although this is the first time I have used JNIENV and
feeling my way and not 100% I'm doing the right thing. I need to make the
Java calls listed below in C# using JNIENV which I've also started to do as
a test below but am getting an error when calling
JNIEnv.CallStaticVoidMethod, saying invalid application configuration which
reading up was suggesting that the airshipconfig.properties might not be
right but the file is the same as my Java Android project and works fine in
there. 

I've included airshipconfig.properties in my assets folder and is identical
settings to the Java project that I have working. I think it maybe where I'm
trying to return the AirshipConfigOptions from loaddefaultOptions method as
I'm not sure what call to make to return a AirshipConfigOptions type with
JNIENV

I was wondering if anyone else had used Urban Airship from Mono For Android
(I have Urban Airship working in MonoTouch fine and also have used C2DM
directly without Urban Airship and that works fine too) and think I could do
with help me with the JNIENV calls. I can provide more detail if anything is
missing here.

Thanks


-> Java Android Code
public class MyApplication extends Application {

@Override
public void onCreate() {

AirshipConfigOptions options =
AirshipConfigOptions.loadDefaultOptions(this);
UAirship.takeOff(this, options);

}

public static com.urbanairship.AirshipConfigOptions
loadDefaultOptions(android.content.Context context) { /* compiled code */ }

public static void takeOff(android.app.Application application,
com.urbanairship.AirshipConfigOptions airshipConfigOptions) { /* compiled
code */ }

-> C# Mono For Android Code

 private void Temp1()
{
  IntPtr ip_airshipConfigOptions =
JNIEnv.FindClass("com/urbanairship/AirshipConfigOptions");

  if (ip_airshipConfigOptions == IntPtr.Zero)
  {
throw new InvalidOperationException("Counldn't find java class !");
  }
   
  IntPtr methodId = JNIEnv.GetStaticMethodID(ip_airshipConfigOptions,
"loadDefaultOptions",
"(Landroid/content/Context;)Lcom/urbanairship/AirshipConfigOptions;");

  if (methodId == IntPtr.Zero)
  {
throw new InvalidOperationException("Couldn't find java class !");
  }

  var methodPtr = JNIEnv.CallStaticObjectMethod(ip_airshipConfigOptions,
methodId, new JValue(this.Application));


  IntPtr ip_uairship = JNIEnv.FindClass("com/urbanairship/UAirship");

  if (ip_uairship == IntPtr.Zero)
  {
throw new InvalidOperationException("Couldn't find java class !");
  }

  // Test different options ???
  IntPtr methodId2 = JNIEnv.GetStaticMethodID(ip_uairship, "takeOff",
"(Landroid/app/Application;Lcom/urbanairship/AirshipConfigOptions;)V");

  // Test different options ???
  IntPtr methodId3 = JNIEnv.GetStaticMethodID(ip_uairship, "takeOff",
"(Landroid/app/Application;)V");

  // Call UAirship.takeOff(this, options). Not sure if these parameters
are specified correctly
  JNIEnv.CallStaticVoidMethod(ip_uairship, methodId2, new
JValue(this.Application), new JValue(methodPtr));
   
}

--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Urban-Airship-Push-Notifications-JNIENV-tp5553668p5553668.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Urban Airship Push Notifications - JNIENV

2012-03-10 Thread Jonathan Pryor
On Mar 10, 2012, at 4:08 PM, GavinBryan wrote:
> [I] am getting an error when calling JNIEnv.CallStaticVoidMethod, saying 
> invalid application configuration

Can you provide the full stack trace?

> I've included airshipconfig.properties in my assets folder

Have you set its Build action to AndroidAsset? If the Build action isn't 
AndroidAsset, it won't be compiled as an asset.

> I think it maybe where I'm trying to return the AirshipConfigOptions from 
> loaddefaultOptions method as I'm not sure what call to make to return a 
> AirshipConfigOptions type with JNIENV

I don't see any code to convert `methodPtr` into an AirshipConfigOptions type, 
though it's largely irrelevant; unless you write an AirshipConfigOptions 
wrapper, the only thing you can wrap it in is a Java.Lang.Object. Useful, but 
not very useful.

As for UAirship.takeOff(Application, AirshipConfigOptions) invocation:

>  IntPtr methodId2 = JNIEnv.GetStaticMethodID(ip_uairship, "takeOff",
> "(Landroid/app/Application;Lcom/urbanairship/AirshipConfigOptions;)V");
> 
>  JNIEnv.CallStaticVoidMethod(ip_uairship, methodId2, new 
> JValue(this.Application), new JValue(methodPtr));

You're doing it right; the above is correct.

 - Jon

___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid