Original address: Android activity exploration
Activity is a component of an application that provides users with a visual interface for user-friendliness, such as dialing a phone, taking a photo, sending an email, or browsing a map. Each activity provides a visual window, which typically covers the entire screen, but in some cases there is a window that is smaller than the screen that floats on another window.
Next we add a new activity to the Android app
The first step is to create a new class that inherits activity, such as: mainactivity
Package com.ljq.activity;
Import android.app.Activity;
Import Android.os.Bundle;
public class Mainactivity extends Activity {
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Use Setcontentview to display a view
Setcontentview (R.layout.main);
}
}
The second step, need to add the activity Configuration code in the function manifest Androidmanifest.xml file
<?xml version= "1.0" encoding= "Utf-8"?>
<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "Com.ljq.activity"
Android:versioncode= "1"
Android:versionname= "1.0" >
<application android:icon= "@drawable/icon" android:label= "@string/app_name" >
<!--. Indicates that mainactivity is the class under current package com.ljq.activity. If the class is under the current package of the app, you can omit the dot symbol, or if the class must be dotted under the applied sub-package,
such as: Mainactivity class under the Com.ljq.activity.user package can be written like this: <activity android:name= ". User. Mainactivity "/>--
<activity android:name= ". Mainactivity "android:label=" @string/app_name ">
<!--
1, an application can have more than one activity, each activity is the same level, then when starting the program, which activity to start first?
Some programs may need to be displayed in the list of programs, some of which are not required. How do you define it?
Android.intent.action.MAIN determines the activity that the application starts first
Android.intent.category.LAUNCHER determines whether the application appears in the program list
2, because your program may have a lot of activity as long as there is such a intent-filter in the XML configuration file, and there is this launcher, then this activity is the first to click on the program to run the activity.
3, now there is only one activity, then add no matter. Used to set the activity to open as default when the emulator starts.
-
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<USES-SDK android:minsdkversion= "7"/>
</manifest>