can anyone please help me? I am trying to enable Parse Local Datastore in a fragment but its throwing out an error: java.lang.IllegalStateException: Parse#enableLocalDatastore(Context) must be invoked before Parse#initialize(Context, String, String). Below is the code I use which works perfectly fine in an Activity but not in Fragment and I know the getActivity context is not null since the second line works.
Parse.enableLocalDatastore(getActivity());
Parse.initialize(getActivity(), DeveloperKey.ParseAppID, DeveloperKey.ParseClientKey);
you have to move your code related to Parse initialization to the Application class. Make class extending Application, add it to manifest and then in the onCreate() of you application call
Parse.enableLocalDatastore(getActivity());
Parse.initialize(getActivity(), DeveloperKey.ParseAppID, DeveloperKey.ParseClientKey);
Reading your logcat error you just need to interchange your code.
Parse.initialize(getActivity(), DeveloperKey.ParseAppID, DeveloperKey.ParseClientKey);
Parse.enableLocalDatastore(getActivity());
When your parse is enables after that you'l be able to enable your local database for it.
I realised using pin() automatically saves to the local datastore so there was no need to explicitly use enableLocaldatastore(). With this, I can query from localdatastore and get the cached result.
Parse.enableLocalDatastore(getActivity());
is an old way of enabling local datastore.
Now you have to do like this.
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId(getResources().getString(R.string.parse_api_key))
.clientKey(null)
.server("YOUR_SERVER_URL/") // The trailing slash is important.
.enableLocalDataStore().build()
);
Try upgrading:
implementation "com.github.parse-community.Parse-SDK-Android:parse:x.xx.x"
To a newer version. Like this:
How android ide did help me out:
Related
Please Help. Im following tutorial on youtube (channel: coding in flow). Its about making a todo app in kotlin using android studio, and i got stuck on this:
taskDao.update(task.copy(completed = isChecked))
Error: Unresolved reference copy.
Tryed a lot of things but didnt help.
task is most likely an instance of a data class which has its own copy() method. If you have access to this class, make sure it is a data class and not a class.
I'm trying to use Realm to store a local database of objects. The app checks if the current session is first load and if so populates the local database with an api call. But, if the database is not empty, I would like to use the data already available. To do this, I need to know whether the database is empty or not.
I found this issue on github, but they dont provide a workaround:
https://github.com/realm/realm-java/issues/766
So how should this be done?
If you scroll down that issue page, you can see Realm.isEmpty() is added. :)
Add a realm.isEmpty() method that returns true if there is no objects
in the Realm. It is just a utility method, but fits nicely with the
Realm object store abstraction.
use realm.isEmpty()
I used
if(realmResults.isEmpty()) {action...}
or
if(realmResults.isNullOrEmpty()) {action...]
there's false but action..
What's wrong!? ...T0T
So, what I'd like to achieve is:
I have a custom class which is basically a HttpRequest, I create the object with url, parameters, etc. And then I have to call execute() to execute it.
I was wondering, is there a way - by annotations, or whatever - to make Android Studio remind me to call this method?
I remember the was something similar with the android Toast, in the IDE a message like 'Did you forget to call show?' was shown if, in fact, I forgot to call show() after creating the Toast.
Thanks much to anyone who will help :)
You could try to create
Create a custom IntelliJ inspection
A custom LINT rule, if you want to check it on your build server and not on your local machine.
I am trying to implement Content Providers and Cursor Loaders to get away from cursors as recommended by Android/Google. However, I'm having a terrible time of it. I'm using the tutorials at http://mobile.tutsplus.com/tutorials/android/android-sdk_content-providers/ as my guide and the simplest thing just isn't working. At the beginning of my Activity, I'm doing the following:
SQLData entry = new SQLData(getApplicationContext());
I've also tried
SQLData entry = new SQLData(this);
SQLData is the name of my database class. What I'd like to do after this line of code is create and populate the database using the methods from the content provider class I've created. However, when I try to move past this line in the debugger, a ClassLoader.class window opens, with the message "source not found". I've reloaded and refreshed and cleaned my package, but this doesn't help. I'm happy to provide all the code for my database and content provider classes, but I'm not sure that's what's needed here. Does anyone know how to approach this issue?
Thanks very much!
In android, or any java dev; you may find it more useful to write JUnit tests and put lots of
Log.v(TAG, "message about " + variable);
in your code instead of using the debugger...
I write Java code as my job and use the debug option maybe twice a year as a last resort...
the JUnit tests get my errors out and save me TONS of time, stepping through code in the debugger can be a very time consuming thing...
just a tip, and it may just be my personal pref...
I am using SSL_Connect() and return code is "-1" , with SSL_get_error() i can see that error is SSL_ERROR_WANT_READ.
As per suggestion on one forum, where it suggested to keep calling SSL_connect() until this error goes. With this modification for first call i am getting error WANT_READ and for second call i am getting SSL_ERROR_SSL. After that for all subsequent calls it is SSL_ERROR_SSL only and as per description of this error it looks something went wrong in SSL library.
Can some one who resolved SSL_connect successfully provide some help.
My code is a plain sequence of calling :
1. SSL_library_init()
2. Creating methods(v23) and context using this meth
3. context has not been modified and it plain as created.
4. SSL object is created using this plain ctx and ssl_connect is called on this ssl after calling SSL_set_fd()
Please let me know if i am doing some thing wrong in this sequence or if i am missing something ?
Is it required to load various things to ctx like certificates and verify locations before using it , if yes what are the bare minimum things required.
Thanks in advance for help.
If it wants a read you have to do a read, or block in select() until OP_READ fires if non-blocking, and then call SSL_Connect() again.
If it wants a write you have to do a write, or block in select() until OP_WRITE fires if non-blocking, and then call SSL_Connect() again.
See here.