Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TommiH · Feb 16, 2013 at 04:46 PM · androidadseclipse

Integrating AdWhirl for Android with Unity

Hello.

We'd like to use AdWhirl on our Unity Android app. However, this is turning out difficult as there's no Prime31 plugin for this combination. As far as I understand, I need to add it in Eclipse, following these instructions: https://www.adwhirl.com/doc/android/AdWhirlAndroidSDKSetup.html

I've managed to create an Eclipse project and add the AdWhirl and AdMob .jar files into my build path (steps 1 and 2). However, as a newbie to Android programming (though not Java), I'm not sure how to integrate the code given in step 4 into the code Unity generated. Should I just add it in the end of the onCreate method? I'm particularly confused by the various views. I'm guessing I shouldn't, at least, duplicate the setContentView call... Here's the code given for the AdWhirl app:

 public class HelloAdWhirl extends Activity implements AdWhirlInterface {
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
  
    AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);
  
    AdWhirlTargeting.setAge(23);
    AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);
    AdWhirlTargeting.setKeywords("online games gaming");
    AdWhirlTargeting.setPostalCode("94123");
    AdWhirlTargeting.setTestMode(false);
  
    AdWhirlLayout adWhirlLayout = (AdWhirlLayout)findViewById(R.id.adwhirl_layout);
    
    TextView textView = new TextView(this);
    RelativeLayout.LayoutParams layoutParams = new
      RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                                  LayoutParams.WRAP_CONTENT);
    int diWidth = 320;
    int diHeight = 52;
    int density = getResources().getDisplayMetrics().density;
  
    adWhirlLayout.setAdWhirlInterface(this);
    adWhirlLayout.setMaxWidth((int)(diWidth * density));
    adWhirlLayout.setMaxHeight((int)(diHeight * density));
  
    layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    textView.setText("Below AdWhirlLayout");
  
    LinearLayout layout = (LinearLayout)findViewById(R.id.layout_main);
    
    layout.setGravity(Gravity.CENTER_HORIZONTAL);
    layout.addView(adWhirlLayout, layoutParams);
    layout.addView(textView, layoutParams);
    layout.invalidate();
  }
 }

And here's the code of the Unity generated activity file that I'm guessing is the one I should add the AdWhirl stuff into:

 package com.horttanagamedev.eurovision;
 
 import com.unity3d.player.*;
 import android.app.Activity;
 import android.content.res.Configuration;
 import android.os.Bundle;
 import android.view.KeyEvent;
 import android.view.View;
 import android.view.Window;
 import android.view.WindowManager;
 
 public class TestProjectActivity extends Activity
 {
     private UnityPlayer mUnityPlayer;
 
     // UnityPlayer.init() should be called before attaching the view to a layout. 
     // UnityPlayer.quit() should be the last thing called; it will terminate the process and not return.
     protected void onCreate (Bundle savedInstanceState)
     {
         super.onCreate(savedInstanceState);
 
         setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
         requestWindowFeature(Window.FEATURE_NO_TITLE);
 
         mUnityPlayer = new UnityPlayer(this);
 
         if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))
             getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
 
         int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
         boolean trueColor8888 = false;
         mUnityPlayer.init(glesMode, trueColor8888);
 
         View playerView = mUnityPlayer.getView();
         setContentView(playerView);
         playerView.requestFocus();
     }
     protected void onDestroy ()
     {
         super.onDestroy();
         mUnityPlayer.quit();
     }
 
     // onPause()/onResume() must be sent to UnityPlayer to enable pause and resource recreation on resume.
     protected void onPause()
     {
         super.onPause();
         mUnityPlayer.pause();
         if (isFinishing())
             mUnityPlayer.quit();
     }
     protected void onResume()
     {
         super.onResume();
         mUnityPlayer.resume();
     }
     public void onConfigurationChanged(Configuration newConfig)
     {
         super.onConfigurationChanged(newConfig);
         mUnityPlayer.configurationChanged(newConfig);
     }
     public void onWindowFocusChanged(boolean hasFocus)
     {
         super.onWindowFocusChanged(hasFocus);
         mUnityPlayer.windowFocusChanged(hasFocus);
     }
 
     // Pass any keys not handled by (unfocused) views straight to UnityPlayer
     public boolean onKeyDown(int keyCode, KeyEvent event)
     {
         return mUnityPlayer.onKeyDown(keyCode, event);
     }
     public boolean onKeyUp(int keyCode, KeyEvent event)
     {
         return mUnityPlayer.onKeyUp(keyCode, event);
     }
 }
 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android game displays 2 game icons 0 Answers

how to integrate unity3d in eclipse IDE? 1 Answer

Admob works on an empty project but not on my actual project 0 Answers

Android Java Proxy could not be found. 0 Answers

StartApp integration 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges