Notice
Recent Posts
Recent Comments
Link
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Tags more
Archives
Today
Total
관리 메뉴

난 정말 최고야 멋있어

android+kotlin 리플렉션을 이용하여 토스트 띄우기 본문

카테고리 없음

android+kotlin 리플렉션을 이용하여 토스트 띄우기

n00bh4cker 2020. 5. 6. 11:37
    fun reflectionExample()
    {
        try {
            val c = Class.forName("android.widget.Toast")
            val m = c.getDeclaredMethod("makeText", Context::class.java,CharSequence::class.java,Int::class.java)
            val show = c.getDeclaredMethod("show")
            val toast = m.invoke(c,applicationContext,"Hello From Reflection",1)
            show.invoke(toast)
        }
        catch (e:Exception)
        {
            e.printStackTrace()
        }
        return
    }