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
2
Question by sjowen · Feb 01, 2015 at 02:46 PM · androidadmobkeyboard

Android keyboard pushes scene up.

Hello folks.

So this is the problem I am having: I have a 2D scene with a sprite for background, several sprite buttons and a GUI textbox. If you touch the textbox, the keyboard opens up and everything is fine. However, once you click on the Google admob banner at the bottom of the screen, press back to exit the browser and get back to the game and then touch the textbox to get the keyboard, the keyboard appears and pushes the entire level upwards. If you close the keyboard, the level goes back to normal. This will continue happening until you close and reopen the game. This however doesn't happen on other ads I have in the game such as Chartboost.

I have googled the problem and tried a few things I found such as adding android:windowSoftInputMode however I think this doesn't apply to Unity builds since nothing I tried made a difference.

I have tried this on several devices with the same results. If you have any ideas how to fix this or something I can try or any more info from me just let me know. Thanks!

Comment
Add comment · Show 7
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
avatar image meat5000 ♦ · Feb 01, 2015 at 03:15 PM 0
Share

https://www.google.co.uk/search?q=android+keyboard+moves+layout&ie=utf-8&oe=utf-8&gws_rd=cr&ei=AEPOV$$anonymous$$vCB4fT7Qbu_YGYBg

avatar image sjowen · Feb 01, 2015 at 03:49 PM 0
Share

Like I said, I have already googled the problem. All the search results say that I have to include android:windowSoftInput$$anonymous$$ode in my manifest. I added it in my main activity and in the admob activity using the values "adjustNothing", "adjustPan" and "adjustResize" separately and still get the same results.

avatar image meat5000 ♦ · Feb 01, 2015 at 03:51 PM 0
Share

Did you see the results that say "How to avoid soft keyboard pushing my layout"?

Like this one, that has a working accepted answer? Did you do it like they did? :)

For example, some say

 android:windowSoftInput$$anonymous$$ode="adjustPan"

to manifest, while others say:

 windowSoftInput$$anonymous$$ode : Ti.UI.Android.SOFT_INPUT_ADJUST_PAN

at window creation.

This is an Android issue, not a Unity one.

It simply seems that your Ad server is making changes that are not being reversed.

avatar image sjowen · Feb 01, 2015 at 04:41 PM 0
Share

I am a little bit confused. The link you posted has things that cannot be used in Unity such as setting view height. Therefore I cannot apply any of the solutions to my game.

Also, the other one "How to avoid soft keyboard pushing my layout", is saying that I have to set isScrollContainer="false" which again does not apply to Unity.

Like I said, all I have are sprites and only one GUI object, the textfield, which I manually disable before the keyboard pops up. I do not have any scrollviews.

EDIT: How do I add code at window creation in Unity?

avatar image meat5000 ♦ · Feb 01, 2015 at 05:27 PM 0
Share

This is why I say it's an Android problem. These things probably need to be linked through the Android API. After all, it is a problem with Android built in $$anonymous$$eyboard and how it is handling the Unity Player, which is linked and utilised through the Android API.

The other things are being applied to the Android $$anonymous$$anifest which is also not a part of Unity.

I would attempt to export my Project to eclipse and adjust the Android API stuff from there.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by guavaman · Aug 05, 2015 at 03:48 AM

Same problem here. None of the suggestions about adding things to the Android manifest worked for me including several others I found on the web. The only thing that worked for me was to hide and show the banner ad after Unity receives focus again.

 void OnApplicationFocus(bool focusStatus) {
     // Hack to fix Google AdMob bug that makes the keyboard push the screen up after application receives focus again
     // after clicking on the banner ad
 #if UNITY_ANDROID
     if(focusStatus && shouldShowBanner) {
         HideBanner();
         ShowBanner();
     }
 #endif
 }

Obviously exact code depends on your implementation.

Comment
Add comment · Share
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
avatar image
0

Answer by Adquizition · Aug 06, 2015 at 02:35 AM

I found a japanese blog post that does fix this with in Unity. I tried to add the line in the manifest file and it didn't seem to affect anything but this nice blog post did, http://westhillapps.blog.jp/archives/40341694.html

Their syntax is off a little so I adjusted it accordingly here:

 using UnityEngine;
 using System.Collections;
 
 public  class  NotScreenResizeAndroid: MonoBehaviour
 {
     void  Start ()
     {
         NotScreenResizeAndroidSetting ();
     }
     
     /// <Summary>
 //    You do not change the screen size with a soft keyboard displayed at the time of the notification bar display set in the /// Android
         /// </ Summary>
     void NotScreenResizeAndroidSetting ()
     {
         #if UNITY_ANDROID
         if (Application.platform != RuntimePlatform.Android)
         {
             return;
         }
         AndroidJNI.AttachCurrentThread ();
         AndroidJNI.PushLocalFrame (0);
         try
         {
 //            Get // Activity
             using (AndroidJavaClass jcUnityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"))
             using (AndroidJavaObject joActivity = jcUnityPlayer.GetStatic <AndroidJavaObject> ("currentActivity"))
             {
                 // Run on the UI thread
                 joActivity.Call ("runOnUiThread", new AndroidJavaRunnable (RunOnUiThread));
             }
         }
         catch (System.Exception ex)
         {
             Debug.LogError (ex.Message);
         }
         finally
         {
             AndroidJNI.PopLocalFrame (System.IntPtr.Zero);
         }
         #endif
     }
     
     /// <Summary>
     /// Run on the UI thread
     /// </ Summary>
     void  RunOnUiThread ()
     {
         #if UNITY_ANDROID
 //        Call the following code: // on the Activity of Android
             // GetWindow () setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING).;
         using (AndroidJavaClass jcUnityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"))
         using (AndroidJavaObject joActivity = jcUnityPlayer.GetStatic <AndroidJavaObject> ("currentActivity"))
         using (AndroidJavaObject joWindow = joActivity.Call <AndroidJavaObject> ("getWindow"))
         {
             joWindow.Call ("setSoftInputMode", 48);
         }
         #endif
     }
 }
 
Comment
Add comment · Share
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

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

22 People are following this question.

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

Related Questions

Inputmode on 18:9 mobile device shows navigation bar 0 Answers

problems with implementing Admob banner ads 0 Answers

deactivate script for period of time after script is used. 0 Answers

Admob interstitial ad not showing up 1 Answer

Missing AdActivity with android:configChanges in AndroidManifest.xml 0 Answers


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