Advance Level QR Code Generator App เคฌเคจाเคจे เคी เคชूเคฐी เคाเคจเคाเคฐी
เคเคธ เคชोเคธ्เค เคฎें เคนเคฎ เคเค เคเคธा Android เคเคช्เคฒीเคेเคถเคจ เคฌเคจाเคंเคे เคो เคिเคธी เคญी เคेเค्เคธ्เค เคฏा เคฒिंเค เคो เคธ्เคाเคเคฒिเคถ QR เคोเคก เคฎें เคฌเคฆเคฒ เคฆेเคा। เคฏे เคชूเคฐा เคช्เคฐोเคेเค्เค เคเคกเคตांเคธ เคฏूเคเค เคे เคธाเคฅ เคกिเคाเคเคจ เคिเคฏा เคเคฏा เคนै, เคिเคธเคฎें เคนเคฎ rounded buttons, glowing effect เคเคฐ glass background เคा เคญी เคเคธ्เคคेเคฎाเคฒ เคเคฐेंเคे।
๐ Project Structure
เคเคชเคो เคจीเคे เคฆिเคฏा เคเคฏा เคชूเคฐा เคซोเคฒ्เคกเคฐ เคธ्เค्เคฐเค्เคเคฐ เคซॉเคฒो เคเคฐเคจा เคนोเคा:
Project Root/
│
├── ๐ java/
│ └── ๐ com/
│ └── ๐ yourapp/
│ └── MainActivity.java
│
├── ๐ res/
│ ├── ๐ layout/
│ │ └── main.xml
│ │
│ └── ๐ drawable/
│ └── btn_rounded.xml
└── glass_background.xml
└── glow_circle.xml
└── gradient_button.xml
└── input_border.xml
│
├── ๐ libs/
│ └── zxing-core-3.5.0.jar
│
├── AndroidManifest.xml
│ └── Permissions
└── android.permission.WRITE_EXTERNAL_STORAGE
└── android.permission.READ_EXTERNAL_STORAGE
│
│
└── dependencies {
implementation 'com.google.zxing:core:3.5.0'
}
๐ฑ Step 1: XML Layout Setup
เคฏเคนां เคนเคฎ เคฏूเค़เคฐ เคंเคเคฐเคซेเคธ เคกिเคाเคเคจ เคเคฐेंเคे เคिเคธเคฎें เคเค EditText, เคเค Generate QR เคฌเคเคจ เคเคฐ เคเค ImageView เคฐเคนेเคा เคเคนां เคชเคฐ QR เคोเคก เคฆिเคाเค เคฆेเคा।
๐ XML Layout เคชेเคธ्เค เคเคฐें: res/layout/main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0F0F1A">
<LinearLayout
android:id="@+id/cardInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="30dp"
android:layout_marginRight="20dp"
android:padding="20dp"
android:background="@drawable/glass_background"
android:orientation="vertical"
android:elevation="8dp"
android:layout_centerHorizontal="true">
<TextView
android:id="@+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Text to Generate QR"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#FFFFFF" />
<EditText
android:id="@+id/inputText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="12dp"
android:background="@drawable/input_border"
android:textSize="14sp"
android:textColor="#FFFFFF"
android:hint="Enter anything..."
android:textColorHint="#607D8B" />
</LinearLayout>
<Button
android:id="@+id/btnGenerate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:layout_marginRight="40dp"
android:background="@drawable/gradient_button"
android:text="GENERATE QR"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:textAllCaps="true"
android:layout_below="@id/cardInput"
android:layout_centerHorizontal="true" />
<ImageView
android:id="@+id/qrPreview"
android:layout_width="240dp"
android:layout_height="240dp"
android:layout_marginTop="30dp"
android:padding="15dp"
android:background="@drawable/glow_circle"
android:src="@drawable/default_image"
android:scaleType="center"
android:layout_below="@id/btnGenerate"
android:layout_centerHorizontal="true" />
<LinearLayout
android:id="@+id/linear2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal"
android:layout_below="@id/qrPreview">
<Button
android:id="@+id/btnDownload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/btn_rounded"
android:text="⬇️ Download"
android:textSize="12sp"
android:textColor="#FFFFFF" />
<Button
android:id="@+id/btnShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/btn_rounded"
android:text="๐ค Share"
android:textSize="12sp"
android:textColor="#FFFFFF" />
</LinearLayout>
</RelativeLayout>
๐ง Step 2: MainActivity.java
เคเคธ เคซाเคเคฒ เคฎें เคชूเคฐा QR เคเคจเคฐेเคถเคจ เคा เคฒॉเคिเค เคฒिเคा เคाเคเคा। เคฏूเค़เคฐ เคा เคเคจเคชुเค เคฒिเคฏा เคाเคเคा เคเคฐ QR เคो ImageView เคฎें เคกिเคธ्เคช्เคฒे เคिเคฏा เคाเคเคा।
๐ Java เคोเคก เคชेเคธ्เค เคเคฐें: java/com/yourapp/MainActivity.java
package com.my.qr;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.content.Intent;
import android.provider.MediaStore;
import java.io.*;
import java.util.*;
import android.net.Uri;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.qrcode.QRCodeWriter;
public class MainActivity extends Activity {
private EditText inputText;
private ImageView qrPreview;
private Button btnGenerate, btnDownload, btnShare;
private Bitmap qrBitmap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getResources().getIdentifier("main", "layout", getPackageName()));
inputText = findViewById(getResources().getIdentifier("inputText", "id", getPackageName()));
qrPreview = findViewById(getResources().getIdentifier("qrPreview", "id", getPackageName()));
btnGenerate = findViewById(getResources().getIdentifier("btnGenerate", "id", getPackageName()));
btnDownload = findViewById(getResources().getIdentifier("btnDownload", "id", getPackageName()));
btnShare = findViewById(getResources().getIdentifier("btnShare", "id", getPackageName()));
btnGenerate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String input = inputText.getText().toString().trim();
if (input.isEmpty()) {
Toast.makeText(getApplicationContext(), "Please enter text", Toast.LENGTH_SHORT).show();
return;
}
generateQR(input);
}
});
btnDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (qrBitmap != null) {
saveToGallery(qrBitmap);
} else {
Toast.makeText(getApplicationContext(), "Generate QR first", Toast.LENGTH_SHORT).show();
}
}
});
btnShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (qrBitmap != null) {
shareImage(qrBitmap);
} else {
Toast.makeText(getApplicationContext(), "Generate QR first", Toast.LENGTH_SHORT).show();
}
}
});
}
private void generateQR(String text) {
QRCodeWriter writer = new QRCodeWriter();
try {
int size = 600;
com.google.zxing.common.BitMatrix bitMatrix = writer.encode(text, BarcodeFormat.QR_CODE, size, size);
qrBitmap = Bitmap.createBitmap(size, size, Bitmap.Config.RGB_565);
for (int x = 0; x < size; x++) {
for (int y = 0; y < size; y++) {
qrBitmap.setPixel(x, y, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE);
}
}
qrPreview.setImageBitmap(qrBitmap);
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Error generating QR", Toast.LENGTH_SHORT).show();
}
}
private void saveToGallery(Bitmap bitmap) {
String saved = MediaStore.Images.Media.insertImage(
getContentResolver(),
bitmap,
"QR_" + System.currentTimeMillis(),
"QR Code"
);
if (saved != null) {
Toast.makeText(getApplicationContext(), "Saved to gallery", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "Save failed", Toast.LENGTH_SHORT).show();
}
}
private void shareImage(Bitmap bitmap) {
try {
File file = new File(getExternalCacheDir(), "qr_share.png");
FileOutputStream out = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
file.setReadable(true, false);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
startActivity(Intent.createChooser(shareIntent, "Share QR via"));
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Share failed", Toast.LENGTH_SHORT).show();
}
}
}
๐จ Step 3: Drawable Files
เคฏूเคเค เคो เคถाเคจเคฆाเคฐ เคฌเคจाเคจे เคे เคฒिเค เคจीเคे เคฆिเค เคเค XML เคซाเคเคฒ्เคธ เคो res/drawable/ เคฎें เคฌเคจाเคं।
- btn_rounded.xml – เคोเคฒ เคฌเคเคจ เคกिเคाเคเคจ เคे เคฒिเค
- glass_background.xml – เคฌ्เคฒเคฐ เคฌैเคเค्เคฐाเคंเคก เคฒुเค
- glow_circle.xml – QR เคोเคก เคे เคाเคฐों เคเคฐ เค्เคฒोเคंเค เคฐिंเค
- gradient_button.xml – เคธुंเคฆเคฐ เค्เคฐेเคกिเคंเค เคฌเคเคจ เคे เคฒिเค
- input_border.xml – เคเคจเคชुเค เคซीเคฒ्เคก เคे เคฌॉเคฐ्เคกเคฐ เคो เคเคธ्เคเคฎाเคเค़ เคเคฐเคจे เคे เคฒिเค
XML drawable เคชेเคธ्เค เคเคฐें: res/drawable/btn_rounded.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#2E86DE" />
<corners android:radius="16dp" />
</shape>
XML drawable เคชेเคธ्เค เคเคฐें: res/drawable/glass_background.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#1FFFFFFF" />
<corners android:radius="16dp" />
</shape>
XML drawable เคชेเคธ्เค เคเคฐें: res/drawable/glow_circle.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#202020" />
<corners android:radius="150dp" />
<stroke android:width="4dp" android:color="#40C4FF" />
</shape>
XML drawable เคชेเคธ्เค เคเคฐें: res/drawable/gradient_button.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#FF512F"
android:endColor="#DD2476"
android:angle="45" />
<corners android:radius="24dp" />
</shape>
XML drawable เคชेเคธ्เค เคเคฐें: res/drawable/input_border.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#202030" />
<corners android:radius="12dp" />
<stroke android:width="1dp" android:color="#AAAAAA" />
</shape>
๐งฉ Step 4: ZXing Library (Sketchware เคฏा Studio)
QR เคोเคก เคฌเคจाเคจे เคे เคฒिเค ZXing เคฒाเคเคฌ्เคฐेเคฐी เคा เคเคธ्เคคेเคฎाเคฒ เคिเคฏा เคเคฏा เคนै।
๐ Sketchware Users:
ZXing เคी .jar เคซाเคเคฒ เคो libs/ เคซोเคฒ्เคกเคฐ เคฎें import เคเคฐें เคเคฐ เคซिเคฐ “Local Library” เคฎें เคोเคก़ें।
๐ Android Studio Users:
app/build.gradle เคฎें เคจीเคे เคฆी เคเค dependency เคोเคก़ें:
๐ Step 5: Permissions
เค เคเคฐ เคเคช QR เคो เคธेเคต เคเคฐเคจे เคा เคซीเคเคฐ เคเคก เคเคฐเคคे เคนैं เคคो เคเคชเคो เคुเค permissions เคी เคเคฐूเคฐเคค เคชเคก़ेเคी:
๐ เคฏे permissions AndroidManifest.xml เคฎें เคोเคก़ें।
๐งพ Final Result & UI Look
เค เคฌ เคเคฌ เคเคช เคธाเคฐी เคซाเคเคฒें เคोเคก़ เคुเคे เคนैं, เคเคชเคा เคเคช เคुเค เคเคธ เคคเคฐเคน เคฆिเคेเคा:
๐ Extra Features เคे เคฒिเค เคธुเคाเคต
- QR เคो เคैเคฒเคฐी เคฎें เคธेเคต เคเคฐเคจे เคा เคตिเคเคฒ्เคช
- Custom Color เคตाเคฒा QR เคोเคก
- QR Scanner เคญी เคोเคก़ें เคเคธी เคเคช เคฎें
- Dark Mode เคธเคชोเคฐ्เค
๐ Conclusion
เคเคธ เคाเคเคก เคे เคเคฐिเค เคเคชเคจे เคเค เคเคกเคตांเคธ เคฒेเคตเคฒ เคा QR เคोเคก เคเคจเคฐेเคเคฐ เคเคช เคฌเคจाเคจा เคธीเคा, เคिเคธเคฎें เคช्เคฐीเคฎिเคฏเคฎ เคฏूเคเค เคเคฐ Java logic เคฆोเคจों เคถाเคฎिเคฒ เคนैं। เค เคฌ เคเคช เคเคธे เคเคฐ เคญी เคฌेเคนเคคเคฐ เคฌเคจा เคธเคเคคे เคนैं — เคฌเคธ เคฅोเคก़ा creativity เคोเคก़ें।
0 เคिเคช्เคชเคฃिเคฏाँ