Android permissions 2 categories mein divide ki gayi hain:
<uses-permission android:name="android.permission.SEND_SMS" />
Is permission ko add karne ka matlab hai ki aapka app SMS bhejne ka intention declare kar raha hai. Ye permission tab check hoti hai jab app install ki ja rahi hoti hai.
To implement SMS functionality in Android, the following steps are required:
SmsManager Android ka primary class hai jo SMS bhejne ke liye use hota hai. Ye developers ko text messages (SMS) aur multimedia messages (MMS) dono bhejne ki facility deta hai. Iske kuch important points hain:
An example usage of SmsManager to send a simple SMS:
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(
"1234567890", // Destination phone number
null, // SMS Center number (null for default)
"Hello, this is a test message!", // Message content
null, // Sent intent (for sent notification)
null // Delivery intent (for delivery notification)
);
Is class ko use karne ke liye AndroidManifest.xml file mein appropriate permission declare karni hoti hai, jaise:
<uses-permission android:name="android.permission.SEND_SMS" />
Android permissions can be divided into two categories:
<uses-permission android:name="android.permission.SEND_SMS" />
Adding this permission means your app declares its intention to send SMS. This permission will be checked when the app is installed.
To implement SMS functionality in Android, the following steps are required:
SmsManager is the primary class in Android used for sending SMS messages. It allows developers to send both text messages (SMS) and multimedia messages (MMS). It provides various methods to customize the message-sending process. Some key points about SmsManager are:
An example usage of SmsManager to send a simple SMS:
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(
"1234567890", // Destination phone number
null, // SMS Center number (null for default)
"Hello, this is a test message!", // Message content
null, // Sent intent (for sent notification)
null // Delivery intent (for delivery notification)
);
This class requires the appropriate permissions in the AndroidManifest file, such as:
<uses-permission android:name="android.permission.SEND_SMS" />
package com.example.mybcaapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
// Method to handle SMS sending
public void sendSMS(View view) {
// Check if the SEND_SMS permission is granted
if (checkSelfPermission(Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED) {
sendMySMS();
} else {
// Request the SEND_SMS permission
requestPermissions(new String[]{Manifest.permission.SEND_SMS}, 1);
}
}
// Method to send SMS
public void sendMySMS() {
String number = "xxxxxxxx89"; // Recipient's phone number
String message = "Hello from Android"; // SMS content
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, message, null, null);
Toast.makeText(this, "SMS sent", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(this, "SMS not Sent", Toast.LENGTH_SHORT).show();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
tools:context=".MainActivity">
<Button
android:id="@+id/sendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send SMS"
android:onClick="sendSMS"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mybcaapplication">
<uses-permission android:name="android.permission.SEND_SMS" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyBCAApplication">
<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>
Sensor ek aisi device hai jo kisi physical quantity ko detect ya measure karke usse ek signal me
convert karti hai jo machine ya system samajh sake.
Simple words me, sensors machines ke liye senses ki tarah kaam karte hain, jise wo apne
environment ko perceive kar sakein, bilkul waise hi jaise humans apni eyes, ears, aur senses ka
use karte hain.
For example, ek temperature sensor heat measure kar sakta hai aur ek light sensor brightness
detect kar sakta hai.
Sensors kaam karte hain kuch steps me, jahan wo physical phenomena ko useful information me convert karte hain:
Sensors kaam karte hain physical quantities jaise temperature, light, ya pressure ke saath interact karke aur unhe electrical signals mein convert karke. Is process ko transduction kaha jata hai. Ye signals phir process kiye jate hain taaki noise remove kiya ja sake aur accuracy badh sake, jo reliable data ensure karta hai. Processed signals ka use information display karne, store karne, ya actions trigger karne ke liye hota hai, jaise tire pressure screen par dikhana ya alarm activate karna.
Sensors alag-alag types ke hote hain, har ek specific physical phenomena detect karne ke liye design kiye gaye hai. Following are some common types of sensors:
Yeh sensors temperature measure karte hain. Common types include:
Yeh sensors light intensity detect karte hain. Types include:
Yeh sensors pressure measure karte hain aur zyada tar industrial aur automotive applications me milte hain. Types include:
Yeh sensors motion ya movement detect karte hain. Examples include:
Yeh sensors chemical properties detect karte hain. Types include:
Sensors kaafi important role play karte hain different fields me, aur inka use almost endless hai. Following are some common applications:
A sensor is a device that detects or measures a physical quantity and converts it into a signal that can be understood by a machine or a system. In simpler terms, sensors act as the senses of machines, helping them to perceive the environment just as humans do with their eyes, ears, and other senses. For example, a temperature sensor can measure heat, and a light sensor can detect brightness.
Sensors operate in several steps, converting physical phenomena into useful information:
Sensors work by interacting with physical quantities like temperature, light, or pressure and converting them into electrical signals through a process called transduction. These signals are then processed to remove noise and enhance accuracy, ensuring reliable data. Finally, the processed signals are used to display information, store it, or trigger actions, like showing tire pressure on a screen or activating an alarm.
Sensors come in many types, each designed to detect specific physical phenomena. Below are some commonly used types:
These sensors measure temperature. Common types include:
These sensors detect light intensity. Types include:
These sensors measure pressure and are often found in industrial and automotive applications. Types include:
These sensors detect motion or movement. Examples include:
These sensors detect chemical properties. Types include:
Sensors play a vital role in various fields, and their applications are nearly endless. Here are some common uses: