I am trying to use this code to filter autocomplete results from google places:
List<Integer> filters = new ArrayList<Integer>();
filters.add(AutocompleteFilter.TYPE_FILTER_ADDRESS);
filters.add(AutocompleteFilter.TYPE_FILTER_CITIES);
mAutocompleteFilter = AutocompleteFilter.create(filters);
but it cannot resolve method AutocompleteFilter.create.
build.gradle:
compile "com.google.android.gms:play-services-maps:11.4.2"
compile "com.google.android.gms:play-services-auth:11.4.2"
compile "com.google.android.gms:play-services-location:11.4.2"
compile "com.google.android.gms:play-services-places:11.4.2"
Is it because of version 11.4.2? I don't want to downgrade. Is there any other alternative to use multiple integers in this AutocompleteFilter?
There is no create method instead use AutocompleteFilter.Builder.
From Docs
Use AutocompleteFilter.Builder to create a new AutocompleteFilter.
mAutocompleteFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.build();
Seems, there are no possibilities to apply several filters via AutocompleteFilter, but you can use PlaceSearch on each separate place type instead of it:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={LAT},{LON}&radius={RADIUS}&type={PLACE_TYPE, e.g. restaurant}&keyword=cruise&key={YOUR_API_KEY}
Related
In android, if i get (SSLSocketFactory) SSLSocketFactory.getDefault() i get the inner socket factory with this class com.android.org.conscrypt.OpenSSLSocketFactoryImpl.
After adding this dependency
dependencies {
implementation 'org.conscrypt:conscrypt-android:2.2.1'
}
I want to get (SSLSocketFactory) SSLSocketFactory.getDefault() the factory from new lib (org.conscrypt.OpenSSLSocketFactoryImpl), but still geting the inner com.android.org.conscrypt.OpenSSLSocketFactoryImpl.
What is the integration algorithm for the new SocketFactory ?
You have to set the Conscrypt provider as first security provider, otherwise it will not be loaded:
Security.insertProviderAt(Conscrypt.newProvider(), 1);
Setting it as first provider will prevent Android from using the default one.
I'm migrating to new google places sdk client and I want to set more than 2 filter to FindAutocompletePredictionsRequest but I can not find the solution
var autoCompleteRequest = FindAutocompletePredictionsRequest.builder().setLocationBias(
bounds).setCountry("TR").setQuery(query).setSessionToken(
AutocompleteSessionToken.newInstance()).setTypeFilter(ADDRESS).build()
As you can see I can only set one filter also I want to set ADDRESS and ESTABLISHMENT together, I tried to set list of filter but doesn't work
sdk version
implementation 'com.google.android.libraries.places:places:1.1.0'
You can just remove setTypeFilter and by default it works with both.
val request = FindAutocompletePredictionsRequest.builder()
.setCountry(country)
.setSessionToken(token)
.setQuery(constraint.toString())
.build()
You can use a binary mask like:
.setTypeFilter(TYPE_FILTER_CITIES|TYPE_FILTER_ADDRESS)
I see a crash whenever my android app initializes a kotlin class. From the stack trace, I see it's from the static initializer of the BuiltInsLoader.Companion object:
kotlin.collections.CollectionsKt___CollectionsKt.first
(CollectionsKt___CollectionsKt.java:166)
kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader$Companion.
(BuiltInsLoader.java:38)
kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader.
(BuiltInsLoader.java)
kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns.createBuiltInsModule
(KotlinBuiltIns.java:150)
kotlin.reflect.jvm.internal.impl.platform.JvmBuiltIns.
(JvmBuiltIns.java:56)
kotlin.reflect.jvm.internal.impl.platform.JvmBuiltIns.
(JvmBuiltIns.java:31)
kotlin.reflect.jvm.internal.components.RuntimeModuleData$Companion.create
(RuntimeModuleData.java:54)
kotlin.reflect.jvm.internal.KDeclarationContainerImpl$Data$moduleData$2.invoke
(KDeclarationContainerImpl.java:35)
kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke
(ReflectProperties.java:93)
kotlin.reflect.jvm.internal.ReflectProperties$Val.getModuleData
(ReflectProperties.java:32)
kotlin.reflect.jvm.internal.KClassImpl$Data$descriptor$2.invoke
(KClassImpl.java:46)
kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke
(ReflectProperties.java:93)
kotlin.reflect.jvm.internal.ReflectProperties$Val.getDescriptor
(ReflectProperties.java:32)
kotlin.reflect.jvm.internal.KClassImpl.getDescriptor
(KClassImpl.java:172)
kotlin.reflect.jvm.internal.KClassImpl.getConstructorDescriptors
(KClassImpl.java:186)
kotlin.reflect.jvm.internal.KClassImpl$Data$constructors$2.invoke
(KClassImpl.java:90)
kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke
(ReflectProperties.java:93)
kotlin.reflect.jvm.internal.ReflectProperties$Val.create
(ReflectProperties.java:32)
The decompiled static block looks like this:
BuiltInsLoader.Companion var0 = new BuiltInsLoader.Companion();
$$INSTANCE = var0;
ServiceLoader var10000 = ServiceLoader.load(BuiltInsLoader.class, BuiltInsLoader.class.getClassLoader());
Intrinsics.checkExpressionValueIsNotNull(var10000, "ServiceLoader.load(Built…::class.java.classLoader)");
Object var1 = CollectionsKt.first((Iterable)var10000);
Has anyone else experienced this crash? If so, how do you fix this initialization error?
This exception can occur if a certain resource file, needed for kotlin-reflect to work correctly, is missing at runtime. The file is located at META-INF/services/kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader. Please verify that no tools remove it during the build and it's present in the final application.
The relevant issue in the Kotlin tracker: https://youtrack.jetbrains.com/issue/KT-20575
Maybe:
packagingOptions {
exclude 'META-INF/services/kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader'
}
Might help
I have an issue with implementing Android AWS Amazon push notification using firebase, in Amazon sample, it shows you to add this line of code
link
AWSMobileClient.defaultMobileClient().getPinpointManager().getNotificationClient().registerGCMDeviceToken(refreshedToken);
But once you add it to the project AWSMobileClient class not initialized so I have added these SDK's
compile 'com.amazonaws:aws-android-sdk-core:2.4.5'
compile 'com.amazonaws:aws-android-sdk-cognito:2.4.5'
compile 'com.amazonaws:aws-android-sdk-pinpoint:2.4.5'
compile 'com.amazonaws:aws-android-sdk-mobileanalytics:2.4.5'
But they didn't initialize, after searching I found that you have to add the sample so I added it
Sample classes
but the classes didn't initialize.
So is there any straightforward example to Initializing this thank you.
Hopefully this helps. You'll need to fill in:
IDENTITY_POOL_ID
APP_ID
Adjust Regions.US_EAST_1 to whichever region you are using.
Code:
CognitoCachingCredentialsProvider cognitoCachingCredentialsProvider = new CognitoCachingCredentialsProvider(context,"IDENTITY_POOL_ID",Regions.US_EAST_1);
PinpointConfiguration config = new PinpointConfiguration(context, "APP_ID", Regions.US_EAST_1, cognitoCachingCredentialsProvider);
PinpointManager pinpointManager = new PinpointManager(config);
pinpointManager.getNotificationClient().registerGCMDeviceToken(refreshedToken);
I have built webrtc for android and have included the jar file in my project. I want to attach data channel to my PeerConnection object. On web, we do following in javascript :
sendChannel = pc.createDataChannel("sendDataChannel", {reliable: true});
or
sendChannel = pc.createDataChannel("sendDataChannel", {reliable: false});
where pc is the PeerConnection.
I want to do same in Java on Android using native webrtc code. I have little confusion. By looking at Jar file on eclipse, I could see that createDataChannel method of PeerConnection takes two arguments of type String and Init.
PeerConnection.createDataChannel(String, Init)
I could not understand what should I put in the second argument. WebRTC documentation, I found, is for web applications. I have seen the following WebRTC draft document but could not understand clearly.
http://www.w3.org/TR/webrtc/#methods-2
It would be helpful if someone can provide a small example of how it should be used.
Currently, I am trying to do this:
DataChannel dc = this.pc.createDataChannel("sendDataChannel", new DataChannel.Init());
You'd create the Init instance and manipulate the public properties before passing it to createDataChannel:
https://code.google.com/p/webrtc/source/browse/trunk/talk/app/webrtc/java/src/org/webrtc/DataChannel.java#35
If you did not find "reliable" there, that is because this does not work anymore. See maxRetransmits and maxRetransmitTimeMs.
Try to make a new Init and assign it a id if you want otherwise just pass new Init() in second argument it will work.