android getWsUrl() - android

The method getWsUrl() is undefined for the type Configuration
for this line
AndroidHttpTransport _ht = new
AndroidHttpTransport(Configuration.getWsUrl());
how can ı solve it?

You probably imported the wrong Configuration. Right now, your import likely points to android.content.res.Configuration.
However, your code snippet suggests you're using (parts of) some Google Code project, androidzon. It has a webservice package that includes a Configuration class with the method you're looking for. It appears to mean something like 'get webservice url'. You will want to correct your import and/or add the missing classes/libraries to your Android project.
Do note that you appear to be using old code, as the latest revision of that Configuration class does not include the getWsUrl() anymore. In stead, there is a getServerAddress() method.

Related

Cannot locate ChangeText class/symbol

I am trying to add some animation in my Android app for a text change on a TextView.
I found a post with sample:
Smooth text change in android animation
Sample code:
TransitionManager.beginDelayedTransition(transitionsContainer,
new ChangeText().setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_OUT_IN));
I have imported the following package:
import androidx.transition.TransitionManager;
However, when I use this, I get an error in Android Studio: Cannot resolve symbol ChangeText
What am I missing? Please help!
The original Answer mentions that a library is needed:
If you want to support Android 4+. check out the Transitions Everywhere lib. You can achieve all sorts of different animations with backward compatibility.
Here you can find some examples.
Therefore you might need to install the library via gradle and then import it like so:
import com.transitionseverywhere.ChangeText;
or
import com.transitionseverywhere.*;

Android, Type argument listadapter

so i'm following a guide online to make a room db. In the adapter section i followed his way of doing it but when i did it, i keep having the "No Type Argument expected for Interface ListAdapter".
Error example: https://imgur.com/kPT7DkE
Here's the whole project so far on github.
https://github.com/OlivierLabelle/BudgetProject/tree/master/app/src/main/java/com/example/android/budgetproject
And the guide i was following.
https://medium.com/#trionkidnapper/recyclerview-more-animations-with-less-code-using-support-library-listadapter-62e65126acdb
So with the help of devboi, i found out i was using the wrong import.
In the top right corner on the Dev documentation it show the right import.
https://imgur.com/vGrCOVd
And here how the import on my project should look like.
import android.support.v7.recyclerview.extensions.ListAdapter
Just came across this very problem myself.
If you're using AndroidX/Jetpack/whatever the official name is I'm still new at this, Android Studio might
import android.widget.ListAdapter
automatically, but the one you want is
import androidx.recyclerview.widget.ListAdapter
From what I see in your code, you should replace ListAdapter<Transaction> with ListAdapter<Transaction, Viewholder>.
You can see an example in the docs here :(https://developer.android.com/reference/android/support/v7/recyclerview/extensions/ListAdapter.html), where ListAdapter has 2 arguments inside the diamonds: one for the list-object and the other for your custom viewholder.
Hope this helps.

Applovin how to initialize sdk in Android

I am trying to initialize the applovin sdk for my react-native app per these instructions: https://developers.google.com/admob/android/mediation/applovin#step_3_import_the_applovin_sdk_and_adapter
On step 3, I am not sure how exactly to use the code AppLovinSdk.initializeSdk(context);. I put it in my MainActivity.java onCreate method, but I get a cannot find symbol error since AppLovinSdk is not defined. What exactly am I missing?
You need this at the top of your Java file
import com.applovin.sdk.AppLovinSdk;
By the way, there's example code here
But, you really should be using an Application class's onCreate rather than an Activity.

Android - IContentService cannot be resolved

In my project I need to use IContentService, and I've used the right import (import android.content.IContentService) and yet android studio tells me 'Cannot resolve symbol IContentService'.
I know IContentService is an actual class, because it is used in ContentResolver.getContentService();
Anyone know how I can get this import to work?
You cannot use this class directly.
You can see in the source code (e.g. here for Marshmallow) that this class is tagged with the #hide annotation.
The class can only be used by reflection as shown here (with all it's disadvantages).
BTW: ContentResolver.getContentService() is also a hidden method (see here).

Unittesting AsyncTaskLoader with getLoaderResultSynchronously

I am trying to create unit tests for a REST client that does some API calls. The client works fine in the live application, but I can't get it to run in the test case.
Apparantly, LoaderTestCase.getLoaderResultSynchronously() could be used here (at least according to Android reference, but it will not accept my loader. The code:
public void testGetEventInfo() {
// Init some vars
...
// Create & execute loader
RESTLoader loader = new RESTLoader(getContext(),
RESTLoader.HTTPVerb.GET, action, params, LOADER_GET_NEWS);
getLoaderResultSynchronously(loader);
}
This yields the error getLoaderResultSynchronously(Loader) in the type LoaderTestCase is not applicable for the arguments (RESTLoader).
RESTLoader extends AsyncLoader. Note that I'm using the supportlibrary, maybe the Loader in there is incompatible? The documentation gives no information on this.
I've tried to solve this in several ways, though none seem to work:
Registered a listener to loader. However, the callback never triggers
Using CountdownLatch (also with a listener). Again, no trigger/countdown timeout.
Playing around with the type template (), without success.
Similar solutions on SO, though again failing to reach the listener.
Does anybody know why getLoaderResultSynchronously will not accept the loader? Or another clean way of testing the Loader, including a way to test return data? I can test handling the return data in a separate case, but I would also like to test the actual data.
Sincerely,
Have you taken a look at the source code? You'll find the following import statements:
import android.content.Loader;
import android.content.Loader.OnLoadCompleteListener;
It doesn't look like Android offers a support version for LoaderTestCase. The easiest solution would be to temporarily change to the non-support LoaderManager (that is, have your class make use of the android.content.Loader instead), test your app, and then switch back to the support implementation. You might also consider copying the testing source code into your project, import the support LoaderManager, and execute it directly. I'm not familiar with the test libraries for Loaders but it doesn't seem outwardly obvious that this would cause any major issues.
You can get sources from LoaderTestCase here, create SupportLoaderTestCase class from that sources in your test project and modify all namespaces to support library namespaces (e.g. change android.content.Loader with android.support.v4.content.Loader). Than you can extend your test case from SupportLoaderTestCase (not from LoaderTestCase) and use it without problems
The method you are trying to call (getLoaderResultSynchronously) accepts an object of type android.content.Loader. If your RESTLoader class is not of that EXACT type then you will get this error. I suspect your class directly or indirectly extends android.support.v4.content.Loader, which would explain the error.
I am not aware of a back-port of LoaderTestCase that would support testing of this type of class.

Categories

Resources