Re: AdMob and NativeActivity - possible?

1,387 views
Skip to first unread message

Philippe Simons

unread,
Oct 22, 2012, 3:55:23 AM10/22/12
to andro...@googlegroups.com
You pinned the issue: there is no view hierachy, thus there is no way to display something else but the native surface view.
The same goes for events (touch) dispatching...

If you want a view hierachy goes with a GLSurfaceView and handle your native rendring in a native callback... not the best solution, but actually the only available.

What you could do, is to split your app, one NativeActivity (with no ads) and the rest with standard Activity.

Sorry, I've lost hope somone found a solution to this, but current NativeActicty is not design for this use case.

On Sun, Oct 21, 2012 at 10:43 PM, Marcin Jakubowski <mjaku...@gmail.com> wrote:
Hello,

I'm trying to glue AdMob and NativeActivity based app. I can send requests through my JNI bridge from native code to Java but since NativeActivity doesn't use view hierarchy for rendering, it's of no use. I've spent two days trying to somehow go around this, I figured it's time to ask - is there any way to use AdMob with NativeActivity? Or is there no hope for me?

Regards,
Marcin

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/O87DLkFTsiQJ.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

a1

unread,
Oct 22, 2012, 6:20:18 AM10/22/12
to andro...@googlegroups.com


W dniu niedziela, 21 października 2012 22:43:53 UTC+2 użytkownik Marcin Jakubowski napisał:
Hello,

I'm trying to glue AdMob and NativeActivity based app. I can send requests through my JNI bridge from native code to Java but since NativeActivity doesn't use view hierarchy for rendering, it's of no use. I've spent two days trying to somehow go around this, I figured it's time to ask - is there any way to use AdMob with NativeActivity? Or is there no hope for me?

Disclaimer: it's just a speculation, I've not tested it. 

Activity window doesn't use view hierarchy but activity may use several windows (eg. for dialog windows), so maybe you can use PopupWindow (http://developer.android.com/reference/android/widget/PopupWindow.html) and put admob banner there.

--
Bart

NoAngel

unread,
Jan 31, 2013, 12:41:04 AM1/31/13
to andro...@googlegroups.com
should be very useful!

2013年1月29日火曜日 6時19分05秒 UTC+9 Carlo Lanzotti:
Hi,

I did managed to get PopupWindow showing Ads on a pure native game. This thread is quite old, but if there are still interest I will write a little article about it.

Best Regards.


Il giorno domenica 21 ottobre 2012 22:43:53 UTC+2, Marcin Jakubowski ha scritto:
Hello,

I'm trying to glue AdMob and NativeActivity based app. I can send requests through my JNI bridge from native code to Java but since NativeActivity doesn't use view hierarchy for rendering, it's of no use. I've spent two days trying to somehow go around this, I figured it's time to ask - is there any way to use AdMob with NativeActivity? Or is there no hope for me?

Regards,
Marcin

Carlo Lanzotti

unread,
Feb 1, 2013, 6:15:18 PM2/1/13
to andro...@googlegroups.com
Hi,

I did all my best, hope it is clear enough. I posted it on my blog so I can give you quick replies:


Best Regards


Il giorno 31/gen/2013, alle ore 23:38, Eli <elih...@gmail.com> ha scritto:

That would be very interesting.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.

To post to this group, send email to andro...@googlegroups.com.

Carlo Lanzotti

DynaDream - Dynamic Laboratory





Dianne Hackborn

unread,
Feb 4, 2013, 9:45:51 PM2/4/13
to andro...@googlegroups.com
On Mon, Oct 22, 2012 at 12:55 AM, Philippe Simons <simons....@gmail.com> wrote:
You pinned the issue: there is no view hierachy, thus there is no way to display something else but the native surface view.
The same goes for events (touch) dispatching...

I just noticed this now, and want to point out that this isn't really true.  NativeActivity is just an activity that gives you an easy way to associate native code with it.  Your native code can completely take over drawing into the window, or it can not, that is up to you.  If you need to mix regular views with OpenGL drawing, then you can do things like use a GLSurfaceView inside of the view hierarchy of a NativeActivity.  The two work fine together, you just need to do your drawing in to the surface view's surface instead of getting to take over the surface of the activity window.

--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Philippe Simons

unread,
Feb 5, 2013, 3:38:36 AM2/5/13
to android-ndk
I'd really like to see a example for this.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.

Leigh McRae

unread,
Feb 5, 2013, 11:28:46 AM2/5/13
to andro...@googlegroups.com
I have 2 cents to offer. I ported my game engine to the NDK and decided
to go with NativeActivity. So now my engine can cross compile to PC,
Android, iOS and BB10. Life was good and the people rejoiced. Started
to hook up AdMob on Android and spent a day annoying anyone who would
listen (poor wife). I have to say that I assumed that AdMob support
would be there for any type of Android app as I thought it was in
Google's interest. Either way, it doesn't really matter.

The next day I tried various hacks that stunk up the code and introduced
new dragons that I knew would come back to burn me. Then I started to
think about other stuff like in app purchases and other features of the
market. I switched off just get it done mode. The solution? Write
your own glue code somewhat like NativeActivity. I tend to wonder if
it's really meant to be used in shipping code. Spend a couple days
tracing through how they do stuff. Basically learn how Android manages
Java and C++ together just like how on iOS you have to learn the Obj-C
crap to C++. Actually be happy it's Java and not Obj-C.

The Android platform is Java and that is all there is to it. Learn JNI
on Android and your app will be much better off IMHO.



On 2/5/2013 3:38 AM, Philippe Simons wrote:
> I'd really like to see a example for this.
>
>
> On Tue, Feb 5, 2013 at 3:45 AM, Dianne Hackborn <hac...@android.com
> <mailto:hac...@android.com>> wrote:
>
> On Mon, Oct 22, 2012 at 12:55 AM, Philippe Simons
> <simons....@gmail.com <mailto:simons....@gmail.com>> wrote:
>
> You pinned the issue: there is no view hierachy, thus there is
> no way to display something else but the native surface view.
> The same goes for events (touch) dispatching...
>
>
> I just noticed this now, and want to point out that this isn't
> really true. NativeActivity is just an activity that gives you an
> easy way to associate native code with it. Your native code can
> completely take over drawing into the window, or it can not, that
> is up to you. If you need to mix regular views with OpenGL
> drawing, then you can do things like use a GLSurfaceView inside of
> the view hierarchy of a NativeActivity. The two work fine
> together, you just need to do your drawing in to the surface
> view's surface instead of getting to take over the surface of the
> activity window.
>
> --
> Dianne Hackborn
> Android framework engineer
> hac...@android.com <mailto:hac...@android.com>
>
> Note: please don't send private questions to me, as I don't have
> time to provide private support, and so won't reply to such
> e-mails. All such questions should be posted on public forums,
> where I and others can see and answer them.
>
> --
> You received this message because you are subscribed to the Google
> Groups "android-ndk" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to android-ndk...@googlegroups.com
> <mailto:android-ndk%2Bunsu...@googlegroups.com>.
> To post to this group, send email to andro...@googlegroups.com
> <mailto:andro...@googlegroups.com>.

Philippe Simons

unread,
Feb 6, 2013, 7:20:53 AM2/6/13
to android-ndk
Almost the same here.

I managed to make my engine runs inside a GLSurfaceView.Renderer, and dropped NativeActivity


On Tue, Feb 5, 2013 at 5:28 PM, Leigh McRae <leigh...@lonedwarfgames.com> wrote:
I have 2 cents to offer.  I ported my game engine to the NDK and decided to go with NativeActivity.  So now my engine can cross compile to PC, Android, iOS and BB10.  Life was good and the people rejoiced.  Started to hook up AdMob on Android and spent a day annoying anyone who would listen (poor wife).  I have to say that I assumed that AdMob support would be there for any type of Android app as I thought it was in Google's interest.  Either way, it doesn't really matter.

The next day I tried various hacks that stunk up the code and introduced new dragons that I knew would come back to burn me.  Then I started to think about other stuff like in app purchases and other features of the market.  I switched off just get it done mode.  The solution?  Write your own glue code somewhat like NativeActivity.  I tend to wonder if it's really meant to be used in shipping code. Spend a couple days tracing through how they do stuff.  Basically learn how Android manages Java and C++ together just like how on iOS you have to learn the Obj-C crap to C++.  Actually be happy it's Java and not Obj-C.

The Android platform is Java and that is all there is to it.  Learn JNI on Android and your app will be much better off IMHO.




On 2/5/2013 3:38 AM, Philippe Simons wrote:
I'd really like to see a example for this.


On Tue, Feb 5, 2013 at 3:45 AM, Dianne Hackborn <hac...@android.com <mailto:hac...@android.com>> wrote:

    On Mon, Oct 22, 2012 at 12:55 AM, Philippe Simons
    <simons....@gmail.com <mailto:simons.philippe@gmail.com>> wrote:

        You pinned the issue: there is no view hierachy, thus there is
        no way to display something else but the native surface view.
        The same goes for events (touch) dispatching...


    I just noticed this now, and want to point out that this isn't
    really true.  NativeActivity is just an activity that gives you an
    easy way to associate native code with it.  Your native code can
    completely take over drawing into the window, or it can not, that
    is up to you.  If you need to mix regular views with OpenGL
    drawing, then you can do things like use a GLSurfaceView inside of
    the view hierarchy of a NativeActivity.  The two work fine
    together, you just need to do your drawing in to the surface
    view's surface instead of getting to take over the surface of the
    activity window.

    --     Dianne Hackborn
    Android framework engineer
    hac...@android.com <mailto:hac...@android.com>


    Note: please don't send private questions to me, as I don't have
    time to provide private support, and so won't reply to such
    e-mails.  All such questions should be posted on public forums,
    where I and others can see and answer them.

    --     You received this message because you are subscribed to the Google
    Groups "android-ndk" group.
    To unsubscribe from this group and stop receiving emails from it,
    <mailto:android-ndk%2Bunsu...@googlegroups.com>.

    To post to this group, send email to andro...@googlegroups.com

    Visit this group at http://groups.google.com/group/android-ndk?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.

To post to this group, send email to andro...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.

Leigh McRae

unread,
Feb 6, 2013, 8:29:42 AM2/6/13
to andro...@googlegroups.com
I skipped GLSurfaceView only because my engine manages a render thread
across that all platforms. So this makes more of my code cross
platform and easier to managed. I still can't get debugging to work on
Android so being able to debug the same render code on Win32 is a real
bonus.



On Wednesday, February 06, 2013 7:20:53 AM, Philippe Simons wrote:
> Almost the same here.
>
> I managed to make my engine runs inside a GLSurfaceView.Renderer, and
> dropped NativeActivity
>
>
> On Tue, Feb 5, 2013 at 5:28 PM, Leigh McRae
> <leigh...@lonedwarfgames.com
> <mailto:hac...@android.com <mailto:hac...@android.com>>> wrote:
>
> On Mon, Oct 22, 2012 at 12:55 AM, Philippe Simons
> <simons....@gmail.com
> <mailto:simons....@gmail.com>
> <mailto:simons.philippe@gmail.__com
> <mailto:simons....@gmail.com>>> wrote:
>
> You pinned the issue: there is no view hierachy, thus
> there is
> no way to display something else but the native
> surface view.
> The same goes for events (touch) dispatching...
>
>
> I just noticed this now, and want to point out that this isn't
> really true. NativeActivity is just an activity that
> gives you an
> easy way to associate native code with it. Your native
> code can
> completely take over drawing into the window, or it can
> not, that
> is up to you. If you need to mix regular views with OpenGL
> drawing, then you can do things like use a GLSurfaceView
> inside of
> the view hierarchy of a NativeActivity. The two work fine
> together, you just need to do your drawing in to the surface
> view's surface instead of getting to take over the surface
> of the
> activity window.
>
> -- Dianne Hackborn
> Android framework engineer
> hac...@android.com <mailto:hac...@android.com>
> <mailto:hac...@android.com <mailto:hac...@android.com>>
>
>
> Note: please don't send private questions to me, as I
> don't have
> time to provide private support, and so won't reply to such
> e-mails. All such questions should be posted on public
> forums,
> where I and others can see and answer them.
>
> -- You received this message because you are
> subscribed to the Google
> Groups "android-ndk" group.
> To unsubscribe from this group and stop receiving emails
> from it,
> send an email to
> android-ndk+unsubscribe@__googlegroups.com
> <mailto:android-ndk%2Bunsu...@googlegroups.com>
> <mailto:android-ndk%__2Buns...@googlegroups.com
> <mailto:android-ndk%252Buns...@googlegroups.com>__>.
>
> To post to this group, send email to
> andro...@googlegroups.com <mailto:andro...@googlegroups.com>
> <mailto:android-ndk@__googlegroups.com
> <mailto:andro...@googlegroups.com>>.
>
> Visit this group at
> http://groups.google.com/__group/android-ndk?hl=en
> <http://groups.google.com/group/android-ndk?hl=en>.
> For more options, visit
> https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
> --
> You received this message because you are subscribed to the
> Google Groups "android-ndk" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to
> android-ndk+unsubscribe@__googlegroups.com
> <mailto:android-ndk%2Bunsu...@googlegroups.com>.
> To post to this group, send email to
> andro...@googlegroups.com
> <mailto:andro...@googlegroups.com>.
> Visit this group at
> http://groups.google.com/__group/android-ndk?hl=en
> <http://groups.google.com/group/android-ndk?hl=en>.
> For more options, visit
> https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "android-ndk" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to android-ndk+unsubscribe@__googlegroups.com
> <mailto:android-ndk%2Bunsu...@googlegroups.com>.
> To post to this group, send email to andro...@googlegroups.com
> <mailto:andro...@googlegroups.com>.
> Visit this group at
> http://groups.google.com/__group/android-ndk?hl=en
> <http://groups.google.com/group/android-ndk?hl=en>.
> For more options, visit https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "android-ndk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to android-ndk...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages