17 -year -old brother, I ca n’t buy a ticket to return to China to attack the airline system to paralyzed and be sentenced to four years! Self -proclaimed girlfriend’s pregnancy pressure is high, …

2023-01-15   ES  

  • Use this, indicating that the current class is the subclass of Context, usually the Activity Application, etc.

This: Represents the current, in Activity, it represents the current Activity.

Activity.This’s Context returns the context of the current Activity, which belongs to Activity. Activity destroys him and destroys

  • Use GetApplicationContext to obtain the Application used by the current app, which is the only specified in Androidmanifest. It means that using this function at any position of the current app is the same context;

GetApplicationContext (): Back to the context of the application, the life cycle is the entire application, the application is destroyed, it is destroyed.

  • Use GetContext to get the Context where the current object is located. Context is usually translated as context. I usually understand it as a scene.
  • GetApplication (): Andorid develops global data in development;
  • GetBaseContext () Return to context set by the constructor specified or setBaseContext ()In our usual development, sometimes some global data may be needed to allow all Activity and View to be accessed in the application. When you encounter this situation, you may first think of yourself defining a class. Then create a lot of static members, but Andorid has provided us with a solution for this situation: in Android, there is a class called Application. We can use GetApplication () in Activity. The application of the application can obtain the theme of the current application, the content of the resource file, etc. This class is more flexible that it can be inherited by us to add our own global attributes.

Reprinted from:https://www.cnblogs.com/bluestorm/p/5842891.html

source

Related Posts

C language writing program calculation freight: f = p*w*s*(1-d). (Realized with the Switch statement)

(8) Centos6.x source code installation postgis (ordinary user)

Connect the server through the IP address and port

django connection MySQL configuration method summarizes dream chase

17 -year -old brother, I ca n’t buy a ticket to return to China to attack the airline system to paralyzed and be sentenced to four years! Self -proclaimed girlfriend’s pregnancy pressure is high, …

Random Posts

30 examples in detail, let the operation and maintenance thoroughly clarify the top command!

Start mysql error: 4’t find messagefile ‘/usr/share/mysql/errmsg.sys

linux shell

linux installation Redissevenand

br a little change tangxiao