Create starting activity in Android studio

If you have been using Eclipse and ADT to develop Android application and now you are switching to Android Studio, you will want to know how to create an Activity in your project. The following steps help you accomplish the task.



1. On the left pane, double-click your project to expand the hierarchy tree.
2. Expand app node. Then expand src node.
3. You select main. Then right-click on the java node. From the popup menu, you select New and then select Activity. Now you can select a type of Activity to be added to you project.

Create-starting-activity-in-Android-studio


After you added a new Activity, you can set it as the starting activity of your application. This task can be done by adding an intent-filter to the activity in AndroidManifest.xml file (app-->src->AndroidManifest.xml). The intent-filter must specify "android.intent.action.MAIN" and "android.intent.category.LAUNCHER" as the names of its <action> and <category> elements.

<activity
        android:name=".FlashActivity"
        android:label="@string/title_activity_flash"
        >
        <intent-filter>
           <action android:name="android.intent.action.MAIN" />
           <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
     </activity>

Posted by: Dara | post date: 02-08-2015 | Subject: Android Apps Development

write programming tip




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.