Android Mobile Programming (AMP) Practicals
- Get link
- X
- Other Apps
Introduction Welcome to this comprehensive guide on Android Mobile Programming (AMP) practicals. If you are a student looking for well-structured and easy-to-follow solutions, you are in the right place. This blog provides downloadable PDFs for all 10 practicals along with step-by-step instructions.
Text file:-Download txt file
Download PDFs for Practicals
Each practical is available as a downloadable PDF. Click the links below to access them:
📱 Practical 1: Download PDF
📱 Practical 2: Download PDF
📱 Practical 3: Download PDF
📱 Practical 4A: Download PDF
Practical 4B: Download PDF
Practical 4C: Download PDF
Practical 4D: Download PDF
Practical 4E: Download PDF
📱 Practical 5: Download PDF
📱 Practical 6A: Download PDF
📱 Practical 6B: Download PDF
📱 Practical 7: Download PDF
📱 Practical 8: Download PDF
📱 Practical 9: Download PDF
📱 Practical 10: Download PDF
Conclusion
By following these practicals, you will gain hands-on experience in Android development. Make sure to download and practice each one carefully. Stay tuned for more updates!
For any queries, feel free to ask in the comments below!
Network connection:-
Activity.xml:-
----------
activity.kt:-
package com.example.broadcast
import android.content.Context
import android.net.ConnectivityManager
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val c=applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networkInfo=c.activeNetworkInfo
if(networkInfo!=null && networkInfo.isConnected)
{
if(networkInfo.type==ConnectivityManager.TYPE_MOBILE)
{
Toast.makeText(applicationContext,"Connected to mobile",Toast.LENGTH_LONG).show()
}
if(networkInfo.type==ConnectivityManager.TYPE_WIFI)
{
Toast.makeText(applicationContext,"Connected to wifi",Toast.LENGTH_LONG).show()
}
}
else
{
Toast.makeText(applicationContext,"You are offline",Toast.LENGTH_LONG).show()
}
}
}
manifest.xml:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
INTENT
MAINCTIVIY.XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:id="@+id/mytext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Entern your message"
android:inputType="textPersonName"
/>
<Button
android:id="@+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="send" />
</LinearLayout>
second.xml:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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=".SecondActivity">
<TextView
android:id="@+id/display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="40dp"
android:text="TextView" />
</LinearLayout>
mainactivity.kt:-
package com.example.intent
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.Button
import android.widget.EditText
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val message = findViewById<EditText>(R.id.mytext)
val btn_send = findViewById<Button>(R.id.send)
btn_send.setOnClickListener {
val intent = Intent(this, SecondActivity::class.java)
intent.putExtra("msg", message.text.toString())
startActivity(intent)
}
}
}second.kt:-
package com.example.intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.TextView
class SecondActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_second)
val text_display = findViewById<TextView>(R.id.display)
val message = intent.extras?.getString("msg") ?: "No message received"
text_display.text = message
}
}
--------------NOTIFICATION---------
<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"
tools:context=".MainActivity">
<Button
android:id="@+id/btn_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="150dp"
android:layout_centerHorizontal="true"
android:text="show Notification" />
</RelativeLayout>
package com.example.notification
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
class MainActivity : AppCompatActivity() {
lateinit var notificationManager:NotificationManager
lateinit var notificationChannel: NotificationChannel
lateinit var builder: Notification.Builder
val channelId="com.examle.notification"
val description="My Notification"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val show=findViewById<Button>(R.id.btn_show)
notificationManager=getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
show.setOnClickListener {
val intent=Intent(applicationContext,MainActivity::class.java)
val pendingIntent=PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationChannel= NotificationChannel(channelId,description,NotificationManager.IMPORTANCE_HIGH)
notificationChannel.enableLights(true)
notificationChannel.lightColor= Color.RED
notificationChannel.enableVibration(true)
notificationManager.createNotificationChannel(notificationChannel)
builder=Notification.Builder(this,channelId)
.setContentTitle("Android")
.setContentText("New message")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent)
}
else{
builder=Notification.Builder(this)
.setContentTitle("Android")
.setContentText("New message")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent)
}
notificationManager.notify(0,builder.build())
}
}
}
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
- Get link
- X
- Other Apps
Comments