Posts

Showing posts with the label android

ARCore : is arcore-preview.apk (= Tango Core app) required to run a ARCore app?

I would like to develop an app using ARCore. I have several questions: Thanks ! No. But much more than the current choice: Google plans to add support for other phones from Samsung, Huawei, LG, and Asus, among others. The goal is to bring ARCore support to “100 million devices at the end of the preview." - source Yes, If u using preview 1 then arcore-preview.apk else if you are using preview2 then install arcore-preview2.apk ARCore is based on the Tango. The service name is display as Tango Core in preview 1 and the servie name is diplay as ARCore in Preview2 Yes, In future they have plan attach the services by default in sdk but not sure(In Progress) and now the Apps can be downloaded from Play Store. Supported Devices are Following Google Pixel, Pixel XL, Pixel 2, Pixel 2 XL Samsung Galaxy S8 (SM-G950U, SM-G950N, SM-G950F, SM-G950FD, SM-G950W, SM-G950U1) Some of the different in Preview 1 and 2 Future Enhancement All of the basic functionality an be handle in 1.0 (l...

Missing TextView data(text) in a fragment

I have a few edittexts and textviews in Fragment A. I use edittexts to get value from user and then I calculate based on my formula and show the result in the textview. For example Edittext A has 1 and Edittext B has 2 and my formula is add so the textview will show the result as 3. Also, there is a button, info on the Fragment A. On clicking this button a new fragment B is displayed using the below code: Now, when I press the back button, I let the system call super.onBackPressed() so that the current Fragment B is removed and I get back Fragment A. MY PROBLEM: Now the edittexts retain all their values, however the value I calculated and displayed on TextViews disappears. I checked onViewStateRestored(Bundle savedInstanceState) method however the parameter savedInstanceState is null. My Question: How do I save/retrieve the values for my textviews? OR where can I call that code again that calculates the data for textviews ?? Using SharedPreferences will solve your issue just save them ...

java.lang.ClassNotFoundException not specifying missing class

I am getting the following error but the weird thing is that it is not specifying the class that is missing: ps.: The error only occurs in production. Emulator/test devices are fine Check Proguard.txt or proguard configuration file. Proguard might be removing some classes while shrinking/obfuscation. If you're using any external libraries, you need to add code to keep those classes in proguard file. Clean the Project then Rebuild the project it may work. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Android NSD Manager Service Registartion

I am using NSD Manager in android app to register a service . But service registration is happening successfully sometimes and sometimes it doesnt happen even for minutes. For the times it doesn't successfully register the service the onRegistrationFailed callback is also not called, so there is no way to debug as to why service registration is not happening. There is no particular pattern that i am able to identify as to when service registration is not happening. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

RecyclerView.clear()? Is there a method to clear() or invalidate a viewholder data individually?

I came across the documentation for AsyncPagedListDiffer. I'm wondering how we can call holder.clear() when holder is a RecyclerView.ViewHolder instance. Maybe they have an in-house method which accommodates this clearance functionality? Yes, in the code sample on that page, UserViewHolder is assumed to be an extension (that you write) of RecyclerView.ViewHolder that implements additional bindTo and clear methods. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to set different Selectors (color) to specific rows in a gridview on Android

I have a gridview of icons with the size of 5x6, total 30 itens. Each one of the rows (there are 6 rows) must have a different selector colour (selector is that colour that appears when an item is pressed). I need to change the select colour of the items no the background. Can u help me with that? enter image description here In your adapter, inside getView() method (or onBindViewHolder()), you can set the background color for a specific row based on current item position (you can use a switch case), By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

GoogleFit distinguish data between from different devices

I am using GoogleFit HistoryAPI for get step data from user. It's working well. However, in my case, I want to distinguish data between from different devices (using same account) because I don't want user using same account for 2 or more devices (it is a game base on step so I don't want user play on 1 device and have achievement on many devices). I found that Device from DataSource#getDevice, Device#getLocalDevice can help me distinguish data between from different devices. Below is info from official docs: To get information about the device for a data source, use the DataSource.getDevice method. The device information is useful to distinguish from similar sensors on different devices, show the device information from a sensor to the user, or process data differently depending on the device. For example, you may be interested in reading data specifically from the a sensor on a wearable device but not from the same type of sensor on the phone. To get a Device instance f...

Android Sensor.TYPE_STEP_COUNTER has update frequency is slower than specified in the Android API

I'm using a Polar m600 watch to record steps. I've tried using SensorManager.registerListener (SensorEventListener listener, Sensor sensor, int samplingPeriodUs) and SensorManager.registerListener ( listener, Sensor sensor, int samplingPeriodUs, int maxReportLatencyUs), both of which do not change the update frequency. There is an update 10-30 seconds into a walking activity but as it continues the update for the step counter is called roughly every 60 seconds. I am unsure of how I can fix this as I've tried the same exact software (and wear os version) for measuring the delay on another watch and it worked within android spec (0-10 seconds updates). This makes me believe it is an error from the manufacturer but am hesitant to assume so. Does anyone have an idea of what could be causing this ? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie ...

Android Studio - Gradle build fails after setting target compatibility to JDK 1.8

I'm having issue with gradle after setting the target compatibility (under File -> Project structure in Android Studio) to 1.8. I've tried to delete the .gradle folder under C:Usersprofile , reboot PC and relaunch Android Studio (which has downloaded all the gradle's stuff again), but nothing seemed to work. I've also tried to delete the .gradle folder in my project's root directory. The problem occurs only with target JDK set to 1.8; if I set that to 1.7 (and if I remove all the JDK 8 stuff, like lambdas) the build runs successfully. These are the logs: I've included this lines in my gradle file but still it does not build successfully. You should make sure you're not using any non-supported Java 8 APIs or features depending on your minSdkVersion . The complete list can be found here. Also make sure you also set on your gradle build, the sourceCompatility to Java 8. I'll post an answer, since I don't found this solution anywhere I've loo...

Issue with ListView selected item color

Image
I've created a list view which shows some data. When the user clicks on a specific item, its color should change. This works, except that every 10th item changes color, not just the item clicked. try add in your activity this shloud make your selction single not multiaple selction By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Failed to resolve: android.arch.persistence.room:runtime: 1.0.0-alpha1

I am unable to compile the following gradle :- Error Message :- Show in File Show in Project Structure dialog It would be of help if somebody could loop in and help me here!! Library has a release version, update your gradle: More: https://developer.android.com/topic/libraries/architecture/adding-components.html I realize that this question is a bit old and that the current version of Room as of today is 1.1.1, but I think that your issue was actually due to the space between the last colon (:) after "runtime" and before the version (in this case, 1.0.0-alpha1). For example, rather than 'android.arch.persistence.room:runtime: 1.0.0-alpha1' it should read 'android.arch.persistence.room:runtime:1.0.0-alpha1' By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies...

Android Billing how to use setAccountId or assign payment to custom identifier

Image
I would like to **allow my users using my app across multiple devices **. Users have to log into my app through firebase auth. Problem is that payments are assigned to account that is signed on the device (google play) , not with account signed into the app.** From firebase auth I can get an email address of the user of my app - this could be used as some unique identifier. Problem visualized: I noticed that in Billing flow there is .setAccountId("some id") I think I could use this to fill in a unique identifier of a user. But how can use it querying purchases? TLDR : All I want to do is to retrieve purchases that are connected to my APP user account, not device account (google play currently logged in user) . To implement billing using accountId , try using the getBuyIntentExtraParams() method which provides additional functionality as compared with getBuyIntent() method. With this method, you may use accountId with the following description: Optional obfuscated string...

How to set minimum DatePicker date to current date

I want to set the minimum date the user can choose in a DatePicker to the current date. I've tried this: That gives me the following exception: How do I do this? The error says you cannot set the minimum date to exactly now. Try subtracting a second: From the source code the minimum date must be before, not equal to, the current date: So you simply need to subtract enough time from now ( System.currentTimeMillis() ) pass date.before(mMinDate) . If you don't want to use a custom dialog. Use this single line code: Check the Android DatePickerDialog set minimum and maximum date code. Here is the examples. Adding this line to your DatePicker Fragment will set the minimum date as current date & disable the previous months. This can help you. Try this This worked perfectly for me. easy and nice. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie polic...

I Keep getting errors in my android studio build

My first error is this My build keeps failing all the time. Whenever I put a widget it say render problem. My build also says that strings.xml: Error: switch is not a valid resource name (reserved Java keyword". The thing is I'm new to android studio and I don't know where to access strings.xml I really need help or else I wont be able to finish a project. strings.xml: Error: switch is not a valid resource name (reserved Java keyword". The thing is I'm new to android studio and I don't know where to access strings.xml Reason: "switch" or "break" or .. , These resource names are Java reserved key keyword, you can't not use these words to name resource. Change to like this: <string name="switch_on">turn on</string> i think someone answered you question about errors, now where you can find strings.xml? easy on the left menu (where you can find activities and stuff like that) go to res > values > strings.xml ...

MalformedURLException: unknown protocol: android

I was trying to adapt the code from this: 3D-model-viewer to my app because I want to insert some models from that kind to show human anatomy. Everything seems fine, I first cloned and tried the original repository, it worked, so I started using that code. After adapting and checking everything's okay and there are no errors marked, I ran the app, but there seems to be an issue. In the original code, the person saves a url like this: I already changed the first part to my project: so I don't think is that, algo I inserted some logs to verify the params aren't null. The class in github is here: SceneLoader.java So, when I get to that point, the Logcat says "unkown protocol: andorid". Here's the complete logcat:   My repository is this, the app runs, there are no errors marked, just when selecting the 3rd option in my menu (it's the first screen) it crashes. I kept the url line like that since I didn't know if the "android://" part was really i...