Skip to content

[Android] Flutter Plugin에서 Context 받기 #5

@moonyoungCHAE

Description

@moonyoungCHAE

[문제 상황]
안드로이드 SDK 함수를 사용하다보면, context가 필요할 때가 많다.
보통 Android Native 개발할 때는 this 혹은 Activity.this 이런 식으로 사용.
But Flutter에서 안됨!


[해결 방법]

  1. getApplicationContext()
    메인 Activity에서는 잘 되지만 다른 클래스에서 사용하면 null이 return된다.
  2. register에 있는 context 사용
    클래스에 register를 생성 후 mRegistrar.context() 이런 식으로 호출하면 된다.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions