블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-25 00:00

[링크] https://als2019.tistory.com/90

 

android 12 변경 사항 정리

이 글은 아래 사이트를 학습하며 작성한 글입니다. https://developer.android.com/about/versions/12/behavior-changes-all?hl=ko 모든 앱 동작 변경 사항 모든앱 동작 변경 사항이란? targetSdkVersion과 관계없이 Android 12

als2019.tistory.com

 

반응형
Posted by blueasa
, |

Android 7(API 24) 이상에서 지원하는 멀티 윈도우를 막으려면 AndroidManifest.xml에 android:resizeableActivity="false"만 추가하면 됐는데,

위 방식은 API 30까지만 가능하고 API 31(Android 12)부터는 화면이 크면 경고는 뜨지만 막히지 않는다.

[참조] https://blueasa.tistory.com/2669

 

[펌] How can I disable multiwindow mode for an Activity in Android N+

In your manifest, you need: android:resizeableActivity="false" So in your manifest file, for each activity that you want to disable the feature in, it would be like: Or, if you want to disable it in your entire app: . . . As for what will happen, Android j

blueasa.tistory.com

[참조2] https://developer.android.com/guide/topics/large-screens/multi-window-support

 

멀티 윈도우 지원  |  Android 개발자  |  Android Developers

멀티 윈도우 지원 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. 멀티 윈도우 모드를 통해 여러 앱이 같은 화면을 동시에 공유할 수 있습니다. 시스템에서

developer.android.com

 

그래서 약간 꼼수로 아래와 같이 처리했다.

 

[차단]

멀티윈도우/팝업윈도우로 갈 때 OnApplicationPause가 작동하기 때문에, OnApplicationPause에서 false 일 때(Pause가 풀릴 때) , Screen의 현재 해상도를 체크해서 내가 사용하는 게임 비율이 아니면 차단하게 함.

    Ex) 가로모드 게임이면, height가 width보다 크면 차단

 

[해제]

멀티윈도우/팝업윈도우에서 정상적인 전체화면 게임으로 돌아와도 OnApplicationPause가 Call 되지 않기 때문에 여기서 처리는 불가능한 걸 확인했다.

그래서 [차단] 할 때, InvokeRepeating을 사용해서 주기적으로 체크(Update를 쓰면 평소에도 Call 되기 때문에 Invoke 사용함)해서 해상도가 내가 사용하는 비율이 맞으면 해제하도록 해놓음.

  Ex) 가로모드 게임이면, width가 height보다 크먼 해제

 

대충 아래와같이 구현해 둠..

void OnApplicationPause(bool _bPaused)
{
    Debug.LogFormat("[OnApplicationPause] {0}", _bPaused);
    // Android에서만 처리하기 위해 Define으로 분기
#if !UNITY_EDITOR && UNITY_ANDROID
    OnApplicationPause_Android(_bPaused);
#elif !UNITY_EDITOR && UNITY_IOS
#endif
}

void OnApplicationPause_Android(bool _bPaused)
{
    // Pause 할 때는 Pass
    if (true == _bPaused)
        return;

    // [Android12(API31) 멀티윈도우 차단
    // Pause 해제 시, 해상도 세로가 가로보다 더 길면 차단(가로모드 게임)
    if (Screen.currentResolution.width <= Screen.currentResolution.height)
    {
        // [Active] UnSupported Resolution Popup
        // (화면을 완전히 가리고, 터치가 안되도록 Collider를 넣음)
        ActivateUnsupportedResolutionPopup(true);

        // 차단 해제 체크용(Update는 항상 돌기 때문에 Invoke로 필요할때만 처리)
        InvokeRepeating("UpdateCheckUnSupportedResolution", 0.1f, 0.1f);
    }
}

void UpdateCheckUnSupportedResolution()
{
    // 해상도가 가로모드 해상도에 맞게 돌아오면 차단 팝업 해제 및 CancelInvoke
    if (Screen.currentResolution.height < Screen.currentResolution.width)
    {
        // [InActive] UnSupported Resolution Popup
        SGT.UIMain.ActivateUnSupportedResolutionPopup(false);

        CancelInvoke("UpdateCheckUnSupportedResolution");
    }
}
반응형
Posted by blueasa
, |

[사용엔진] Unity 2020.3.37f1

-------------------------------------------------------------------------------------------

[추가]

Push 관련해서 같은 에러가 나서 확인해보니 아래 링크와 같은 처리를 요구하고 있다.

 

1. Android 12 이상에 대해서 PendingIntent 를 PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE 추가

2. AndroidManifest.xml  SCHEDULE_EXACT_ALARM 퍼미션 추가

<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />

>> 1.2. 둘다 처리가 필요할 듯 하다.

 

 

[참조] https://github.com/radishmedia/react-native-push-notification/pull/19

 

fix: fix for not receiving notification on android 12 by tjkang · Pull Request #19 · radishmedia/react-native-push-notificatio

Description 안드로이드에서 sdk version 을 31 로 업그레이드하고 compileSdkVersion = 31 targetSdkVersion = 31 notification 이 수신이 안되는 이슈입니다 이는 안드로이드 12 이상에 대해서 PendingIntent 를 PendingIntent.F

github.com

-------------------------------------------------------------------------------------------

 

구글에서 API 31을 쓰라고 해서 Target API를 31로 올리고 빌드 했는데,

실행은 되지만 최신 폰(좀 안좋은 폰은 정상)에서 실행 중 아래와 같은 에러메시지를 띄우면서 크래시가 남.

----

AndroidJavaException: java.lang.IllegalArgumentException: com.xxx.xxx.xxx: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    java.lang.IllegalArgumentException: com.xxx.xxx.xxx: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

----

이리저리 찾아보니 크게 2가지 처리를 하는 것 같다.

1. AndroidManifest.xml에 exported 명시적으로 설정

2. gradle의 dependencies {}에 androidx.work:work-runtime:2.7.0 라이브러리 추가(for Java)

    - 2.7.0부터 Android 12(API31)대응을 해서 2.7.0이상을 추가하면 되는 듯

    - Unity는 mainTemplate.gradle의 dependencies {...}에 추가

    - 라이브러리 선택 사항

       = [Java] implementation 'androidx.work:work-runtime:2.7.0'  // for Unity

       = [Kotlin] implementation 'androidx.work:work-runtime-ktx:2.7.0

 

 

내 경우는 exported 관련은 이미 돼 있어서 아래와 같이 androidx.work:work-runtime:2.7.1(현재 기준 공식 최신버전)을 추가하고 해결 했다.

mainTemplete.gradle

    dependencies{

    ....

    implementation 'androidx.work:work-runtime:2.7.1'    // for Java

    ....

    }

 

[참조] https://textbox.tistory.com/entry/android-%EC%8B%A4%ED%96%89%EC%98%A4%EB%A5%98-version-31%EC%97%90%EC%84%9C-%EC%95%B1-%EC%8B%A4%ED%96%89%EC%8B%9C-%EC%98%A4%EB%A5%98

[참조] https://bacassf.tistory.com/166

[참조] https://onlyfor-me-blog.tistory.com/467

[참조] https://stackoverflow.com/questions/68228666/targeting-s-version-10000-and-above-requires-that-one-of-flag-immutable-or-fl

반응형
Posted by blueasa
, |