Files
J1B4-Fitbot/docs/documentation/android/appSetup.md
2024-04-23 12:24:37 +02:00

1.3 KiB

Setting up a android app

How to make your project from a empty project

Layout

You first need to make the layout of the app. This can be done in the res folder where you can make a android recource file. When you open that file you can drag and drop elements in the layout.

Code

Then need to make the main class. The class will probably look like this.

package com.fitbot.fitbot;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // set activity_main to your respective layout file
        setContentView(R.layout.activity_main);
    }
}

Manifest

For the app to be able to build you need to add the activity to the manifest file. You can do this by adding this to the manifest file.

        <activity android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

The class name that is ran first is defined in the first line of the class.