the code below will set the button to clickable after 30 sec:
btnOk.isClickable=false
Timer().schedule(timerTask { btnOk.isClickable=true }, 1000*30)
the above code runs in a separate thread,
so the UI is responsive while running this code.
the code below will set the button to clickable after 30 sec:
btnOk.isClickable=false
Timer().schedule(timerTask { btnOk.isClickable=true }, 1000*30)
the above code runs in a separate thread,
so the UI is responsive while running this code.
doAsync {
// Normal code inside Async thread
I=I+1
If(I=100){ uiThread { tvResult.setText =”I is now 100!!”
}
}
//More code
If(x==0){
uiThread { tvResult.setText =”there’s some problem!”
}
}
}
Request user to give permission to read external storage in Android - (Kotlin)
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Permission is not granted // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) { } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), READ_STORAGE_CODE); } } else { // Permission has already been granted}
NOTE: READ_STORAGE_CODE is just an int constant with fix value like 1001, or 2023
and is a variable in class level.
identity
column in that table by using the following code:
SELECT col1, col2, col3=count(*)
INTO holdkey
FROM t1
GROUP BY col1, col2
HAVING count(*) > 1
Select the duplicate rows into a holding table, eliminating duplicates in the process. For example: SELECT DISTINCT t1.* INTO holddups FROM t1, holdkey WHERE t1.col1 = holdkey.col1 AND t1.col2 = holdkey.col2
At this point, the holddups table should have unique PKs, however, this will not be the case if t1 had duplicate PKs, yet unique rows (as in the SSN example above). Verify that each key in holddups is unique, and that you do not have duplicate keys, yet unique rows. If so, you must stop here and reconcile which of the rows you wish to keep for a given duplicate key value. For example, the query: SELECT col1, col2, count(*) FROM holddups GROUP BY col1, col2 should return a count of 1 for each row. If yes, proceed to step 5 below. If no, you have duplicate keys, yet unique rows, and need to decide which rows to save. This will usually entail either discarding a row, or creating a new unique key value for this row. Take one of these two steps for each such duplicate PK in the holddups table.
Delete the duplicate rows from the original table. For example: DELETE t1 FROM t1, holdkey WHERE t1.col1 = holdkey.col1 AND t1.col2 = holdkey.col2
Put the unique rows back in the original table. For example: INSERT t1 SELECT * FROM holddups
to run the below command , start PowerShell in visual studio. Select the database project. In PowerShell: Script-Migration this command wi...