deepeweb.github.io

First Android Sample Application (Hello World App)

अगर आप Android Development सीखना चाहते हैं, तो सबसे पहला कदम एक Basic Android Application बनाना होता है। यहां हम Hello World App बनाएंगे, जो Android Studio में आसानी से run हो सके।

1. Prerequisites (जरूरी चीजें)

इस app को बनाने के लिए आपके पास निम्नलिखित चीजें होनी चाहिए:

2. नया Android Project बनाना

Android Studio खोलें और "New Project" पर क्लिक करें।

Empty Activity टेम्पलेट चुनें और Next पर क्लिक करें।

नीचे दी गई जानकारी भरें:

Finish पर क्लिक करें।

3. MainActivity.java (App का Main Code)

यह कोड MainActivity.java फाइल में होता है, जो ऐप का मुख्य भाग है।

package com.example.helloworld;

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

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // TextView को अपडेट करना
        TextView textView = findViewById(R.id.textView);
        textView.setText("Hello, World!");
    }
}

4. Layout File (activity_main.xml)

यह फाइल res/layout/activity_main.xml में होती है और UI को define करती है।

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center"
    android:padding="16dp">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Welcome!"
        android:textSize="24sp"
        android:textStyle="bold"
        android:textColor="#000000"/>

</LinearLayout>

5. Manifest File (AndroidManifest.xml)

यह फाइल ऐप की configuration को define करती है।

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.helloworld">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="Hello World App"
        android:theme="@style/Theme.AppCompat">

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

    </application>

</manifest>

6. App को Run करना

Android Emulator चलाएं (या USB Debugging ऑन करके फोन connect करें)।

Run App Button (▶️) दबाएं।

App खुलेगा और screen पर "Hello, World!" दिखाई देगा।




Request

अगर आपको यह article useful या interesting लगा हो, तो please इसे अपने dosto aur family ke साथ जरूर share करें। आपका एक छोटा सा कदम हमें और अच्छा content बनाने के लिए motivate करता है। Thank you!

ध्यान दें कि इस page पर आपको कुछ ads भी देखने को मिल सकते हैं। इसके लिए हम आपसे माफी चाहते हैं। हम इस content को तैयार करने में काफी मेहनत और time लगाते हैं, ताकि आपको valuable जानकारी मिल सके। इन्हीं ads की मदद से हम ये काम continue कर पाते हैं।

आपके support और understanding के लिए दिल से धन्यवाद।





Ad
Ad


Ad
Ad

Follow Us

Facebook Logo    Instagram Logo