What is 'Context' on Android?

前端 未结 30 3010
南旧
南旧 2020-11-21 04:46

In Android programming, what exactly is a Context class and what is it used for?

I read about it on the developer site, but I am unable to understand it

30条回答
  •  悲哀的现实
    2020-11-21 05:25

    Context means Android get to know in which activity I should go for or act in.

    1 - Toast.makeText(context, "Enter All Details", Toast.LENGTH_SHORT).show(); it used in this. Context context = ActivityName.this;

    2 -startActivity(new Intent(context,LoginActivity.class));

    in this context means from which activity you wanna go to other activity. context or ActivityName.this is faster then , getContext and getApplicatinContext.

提交回复
热议问题