First, the log system in Android
Two logs commonly used in 1.java
System.out.println ();//Normal log
System.err.println ();//Warning log
Types of logs commonly used in 2.android
LOG.E (TAG, "error message");
LOG.W (Tag, "warning message");
LOG.I (Tag, "General Information");
LOG.D (Tag, "debug Information");
LOG.V (Tag, "useless Information");
PS: This log.v magical place is that it does not use, it is the meaning of existence for developers to entertain themselves, oh hehe ...
Second, the authorization system in Android
1.android Common usage rights
In the development process, sometimes we need to apply to access the user's network, contacts, cameras, front camera, handset and so on devices or power, you need to apply for these components of the permissions for the user to choose, the user can choose to give the app these permissions, you can also deny these permissions.
Add permissions: Add <uses-permission android:name= "" to the Androidmanifest.xml file/>
2. Permission Checking for code
In addition to the system-defined permissions, developers can customize the permissions themselves, such as the need to get custom permissions when executing certain code.
How to use:
Create a new class Hello.java
Public classhello{ Public Static FinalString Permission_say_hello = "Com.example.demo.permission.sayHello"; Public Static voidSayHello (Context context) {intCheckresult =context.checkcallingorselfpermission (Permission_say_hello); if(checkresult!=packagemanager.permission_granted) { Throw NewSecurityException ("Perform ... Need...... The Permissions "); } log.i ("Info", "Hello Android"); }}
The Permission_say_hello constant permissions defined above need to be declared in the Androidmanifest.xml file
<android:name= "Com.example.demo.permission.sayHello"/>
If you want to see the output Hello Android, you need to add permissions in the Androidmanifest.xml file
<android:name= "Com.example.demo.permission.sayHello"/>
3. Add permissions for the base component
Create a Activity,myaty
Declaring a permission in the Androidmanifest.xml file
<android:name= "Com.example.demo.permission.MyAty"/>
Add a permission property to the Myaty tag
android:permission= "Com.example.demo.permission.MyAty"
It is important to note that this permission is not required for components such as in-app startup activity, and only required when cross-app startup.
At the same time, not just the activity, the other three basic components can also add permissions. The Add method is similar.
At this point, the notes for Android entry are all over. The following time begins to summarize the knowledge of the Android interface article. Come on!
Introductory article: 11. Log system and permission system in Android