Is there any difference between Activityname.this() & this?

前端 未结 2 766
情书的邮戳
情书的邮戳 2021-01-14 02:16

Is there any difference between Activityname.this() & this in Android?

I am trying to open an activity from same activity with button i

2条回答
  •  清歌不尽
    2021-01-14 02:26

    no MyActivity.this is the same thing as just using this when you are in the activity itself and not something like a runnable where this would refer to the runnable and not the context

    you should always use this or getActivity() if in a fragment and never use getApplicationContext()

    check here for why you shouldn't use getApplicationContext()

    getApplication() vs. getApplicationContext()

提交回复
热议问题