Personal blog, fix your computer blog, best blog ever blog.

Kickstarter - KONE Coffee Filter Brewing System

and backed.

Source: programmerryangosling

This is how i feel everyday

This is how i feel everyday

(via welliwanttodie)

Source: pushthemovement

Text

I looked high and low for the admob 6 binding for mono droid and I stumbled upon an article from Greg Shackles. In his example he shows you you can combing the JavaLibrary and a JavaSource file using JNI calls to easily integrate ads. However he was using an older AdMob Java Library and I wanted to use the latest and greatest. I posted on the Xamarin news letter and people had some good ideas so I decided to create a git out of it.

Pre-requisits:
1.) Sign up for a Google Ad Mob Account
2.) You MUST register an app so you can get your publisher ID!
3.) Download SDK or my git
4.) Mono for Android (obvy).

Alright so now where to start. First go ahead and add the Jar File for the SDK to the project. Select the .jar file and under Properties set the BuildAction to “AndroidJavaLibrary”.

Create a new file and let’s call it “AdMobHelper.java”. This will be our java file which we will call in our .cs fil and then this one will call the .jar file… make sense??? I like to call it a “JarWrapper”


package yourpackagename.admob;

import android.view.View;
import com.google.ads.*;

public class AdMobHelper
{
	private AdMobHelper() { }

	public static void loadAd(View view)
	{
		((AdView)view).loadAd(new AdRequest());
	}

	public static void destroy(View view)
	{
		((AdView)view).destroy();
	}
}



Alright so what this did is basically make a bunch of static methods that we can pass a view into which we can then call the jar with. New up is to create our C# helper. So create “AdMobHelper.cs”. Inside of here we just have 2 methods as well.


private static IntPtr _helperClass = JNIEnv.FindClass("yourpackagename/admob/AdMobHelper");

        public static void LoadAd(View view)
        {
            IntPtr methodId = JNIEnv.GetStaticMethodID(_helperClass, "loadAd", "(Landroid/view/View;)V");
            JNIEnv.CallStaticVoidMethod(_helperClass, methodId, new JValue(view));
        }

        public static void Destroy(View view)
        {
            IntPtr methodId = JNIEnv.GetStaticMethodID(_helperClass, "destroy", "(Landroid/view/View;)V");
            JNIEnv.CallStaticVoidMethod(_helperClass, methodId, new JValue(view));
        }



This is pretty straight forward as this static class is what we will call. Next up is to setup the manifest file. So open up AndroidManifext.xml. It is important that we have the TargetSdkVersion set to 13!!

You will want to add this:


And also the INTERNET and ACCESS_NETWORK_STATE permissions.

Lastly simply open up you .axml layout file and add the namespace:
xmlns:ads=”http://schemas.android.com/apk/lib/com.google.ads”

then add the actual adview:


You MUST update the adUnitID!!!! This is very very important!!!!

and boom here you have it.

for more check out my git: https://github.com/jamesmontemagno/MonoDroid-Admob6

Source: programmerryangosling

>