Skip to content

Instantly share code, notes, and snippets.

View mumayank's full-sized avatar

Mayank Mohan Upadhyay mumayank

View GitHub Profile
https://googlesecured.page.link/android_root_article_1
https://googlesecured.page.link/android_root_article_2
https://googlesecured.page.link/android_root_article_3
https://googlesecured.page.link/android_root_article_4
https://googlesecured.page.link/android_root_article_5
https://googlesecured.page.link/android_root_article_6
https://googlesecured.page.link/android_root_article_7
https://googlesecured.page.link/android_root_article_8
https://googlesecured.page.link/android_root_article_9
https://googlesecured.page.link/android_root_article_10
// got a new frame from the Android device's camera
doAsync {
// process the frame to get some meaningful data
uiThread {
// show result to the user
// Suppose further processing is required
doAsync {
// process further to get more meaningful data
uiThread {
// show final result to the user
public static ArrayList<String> getRandomColorListEqualToDataSize(ArrayList<String> colorList, int dataSize) {
ArrayList<String> randomNewColorList = new ArrayList<String>();
if (colorList == null || colorList.size() == 0 || dataSize == 0) {
return randomNewColorList;
}
int randomIndex = new Random().nextInt(colorList.size());
for (int i=0; i<dataSize; i++) {
int index = i + randomIndex;
dependencies {
implementation 'com.github.mumayank:AirLocation:LATEST_VERSION' // this line
}
allprojects {
repositories {
...
maven { url 'https://jitpack.io' } // this line
}
}
airLocation = AirLocation(this, true, true, object: AirLocation.Callbacks {
override fun onSuccess(location: Location) {
// location fetched successfully, proceed with it
}
override fun onFailed(locationFailedEnum: AirLocation.LocationFailedEnum) {
// couldn't fetch location due to reason available in locationFailedEnum
// you may optionally do something to inform the user, even though the reason may be obvious
}
override fun onSuccess(location: Location) {
// location fetched successfully, proceed with it
}
override fun onFailed(locationFailedEnum: AirLocation.LocationFailedEnum) {
// couldn't fetch location due to reason available in locationFailedEnum
// you may optionally do something to inform the user, even though the reason may be obvious
}
})
class MainActivity : AppCompatActivity() {
private var airLocation: AirLocation? = null // ADD THIS LINE ON TOP
...
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
airLocation?.onActivityResult(requestCode, resultCode, data) // ADD THIS LINE INSIDE onActivityResult
super.onActivityResult(requestCode, resultCode, data)
}
implementation 'com.google.android.gms:play-services-location:16.0.0'
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />