Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
Q5
val p=this.getSharedPreferences(PREFERENCE_NAME,Context.MODE_PRIVATE)
Q6
Q7