First Android Sample Application (Hello World App)
अगर आप Android Development सीखना चाहते हैं, तो सबसे पहला कदम एक Basic Android Application बनाना होता है। यहां हम Hello World App बनाएंगे, जो Android Studio में आसानी से run हो सके।
1. Prerequisites (जरूरी चीजें)
इस app को बनाने के लिए आपके पास निम्नलिखित चीजें होनी चाहिए:
- Android Studio (इंस्टॉल करें: Download Here)
- Java/Kotlin का basic knowledge
- Android Emulator या Physical Device
2. नया Android Project बनाना
Android Studio खोलें और "New Project" पर क्लिक करें।
Empty Activity टेम्पलेट चुनें और Next पर क्लिक करें।
नीचे दी गई जानकारी भरें:
- Application Name: HelloWorldApp
- Package Name: com.example.helloworld
- Language: Java (या Kotlin)
- Minimum SDK: API 21 (Lollipop) (Recommended)
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
Leave a Comment
INITIALIZING...
INITIALIZING...
Comments Total: 0 comments