Sei sulla pagina 1di 3

Q1

1. Permission of required from users


2. its hold components of app like activities,services,Broadcast Recivers and content providers. Each
component must define basic properties such as the name of its Kotlin or Java class. It can also declare
capabilities such as which device configurations it can handle, and intent filters that describe how the
component can be started
3. The hardware and software features the app requires, which affects which devices can install the app
from Google Play
4. The app's package name

Q2

Var NameThread=Thread(object:Runnable {
public override fun run() {
SystemClock.sleep(5000) // Sleep 4 seconds
// Now show Toast. Needs to be done on the UI thread
runOnUiThread(object:Runnable {
public override fun run() {
Toast.makeText(this,"name : Fareeq and Rollno:---",Toast.LENGTH_SHORT).show()
}
})
}
})
NameThread.start()

Q3

These all are methods that’s override when work with loction

1) public void onLocationChanged(Location location) this method called when the location change and new
location is get my location listener and its gives to the app mean latest location.
2) public void onStatusChanged(String provider, int status, Bundle extras) : Called when the provider status
changes.

3) public void onProviderEnabled(String provider) : Called when the provider is enabled by the user mean
GPS

4) public void onProviderDisabled(String provider): Called when the provider is disabled by the user.

Q4

Activity An Activity is an application component that provides a screen with which users
can interact in order to do something, such as dial the phone, take a photo, send an email,
or view a map.
A Service is an application component that can perform long-running operations in the
background and does not provide a user interface. Another application component can start
a service and it will continue to run in the background even if the user switches to another
application.
Code:
1) StartActivty
val intent = Intent(this, SolveFinalExamActivity::class.java)
intent.putExtra("name","Fareeq")
startActivity(intent)

2) StartService

val intent = Intent(getApplicationContext(), FinalExaminvigilationServiceclass.java)


intent.putExtra("name","Fareeq")
startService(intent)

Q5

val p=this.getSharedPreferences(PREFERENCE_NAME,Context.MODE_PRIVATE)

Toast.maketext(this,”Name${ p.getString(studentName,”brother ham phir direct whatsapp


pa bat krta yahan rhna do fiveer pa yam era num 03341617255”)} age: ${
p.getString(StudentAge,22)} GPA: ${ p.getArray(StudentGPAarr,[])}
,Toast.LENGTH_SHORT).SHOW()

Q6

Q7

private fun notification(Message:String,Title:String) {


val intent = Intent(this,PostnotificationActivity::class.java)
val pendingIntent = PendingIntent.getActivity(this, 0 /* request code */, intent,
PendingIntent.FLAG_UPDATE_CURRENT)
val builder = NotificationCompat.Builder(this,
"mychannel").setContentTitle(Title)
.setContentText(Message)
.setSmallIcon(R.drawable.notification_icon_ehelp)
.setContentIntent(pendingIntent)
//.setOnlyAlertOnce(true)

val mNotificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as


NotificationManager

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {


val channel = NotificationChannel("mychannel",
"Channel human readable title",
NotificationManager.IMPORTANCE_HIGH)
mNotificationManager.createNotificationChannel(channel)
}

val notification = builder.build()


 mNotificationManager.notify(0, notification)
}

Potrebbero piacerti anche