I’m not sure why I’m getting this error only on certain Android versions (below 5.0).
I’m calling:
myImageView.setImageDrawable(getResources().getDrawable(R.drawable.image, null));
Because of this I’m getting a NoSuchMethodError.
What to do?
Use this
myImageView.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.image));
Instead of this
myImageView.setImageDrawable(getResources().getDrawable(R.drawable.image, null));
EDIT
when you use setImageDrawable(getResources().getDrawable(R.drawable.image, null)); this it will shows below error
NOTE setImageDrawable(getResources().getDrawable(R.drawable.image, null)); this method is added in API level 21
You can read more about ContextCompat
Use ContextCompat, it's helper class for accessing features in
Context.
Using this class you can easily access the following resources,
ImageDrawable
String
Colour
ColorStateList
CodeCacheDir
And many more...
Try by following way,
myImageView.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.image));
#Prem answer is the right one. Just adding this to provide you with a tip.
In Android documentation there is an indication of which API level included each method. For example, the one you're using was introduced in Android 5.0 (API level 21).
You are calling
getResources().getDrawable(R.drawable.image, null) method which is added in API level 21
check Android docs
If you are using second parameter (theme) as a null
So try to use
getResources().getDrawable(R.drawable.image);
You can use following code for the same
myImageView.setImageDrawable(getResources().getDrawable(R.drawable.image));
Related
I am aware of the fact that I am able to use a HTTP request to use the distance matrix API (i.e. https://maps.googleapis.com/maps/api/distancematrix/json?origins=42.11622,78.10112&destinations=40.82231,72.224166&key=YOUR_API_KEY)
But I would like to simply use the Java API instead. From my understanding the first step is to create a GeoApiContext and this seems to be where I am failing. I have tried the following code:
private static GeoApiContext context = new GeoApiContext.Builder().apiKey("MyKey").queryRateLimit(500).build();
However I am just met with the following compile error:
java.land.NoClassDefFoundError: com/google/common/util/concurrent/RateLimiter
Any help on the matter would be appreciated. The plan is to use this to create a DistanceMatrix API request if that helps.
check out this link you may find it useful... there are code examples
https://www.programcreek.com/java-api-examples/index.php?api=com.google.maps.model.DistanceMatrix
I've updated to elasticsearch java library version 5.2.0.
In 2.x,
I was using SearchRequestBuilder.addField() in order to add a field to the search request. Nevertheless, It seems to be replaced. I've written the available methods intellisense is showing me. Which of them do I need to pick?
addDocValueField
addFieldDataField
addScriptField
addStoredField
storedFields
fields
SearchRequestBuilder.setNoFields is also removed. Which would be the alternative?
Currently, I'm calling scripts from Java using this code. Is there any more elegant way to call it in 5.x Java API?
Code:
return AggregationBuilders
.terms(this.getName())
.field(this.getName())
.script(new Script(
ScriptType.FILE,
"painless",
"year",
ImmutableMap.of("field", this.getName())
)
);
As you can see I setting field as script parameter. Nevertheless, I don't quite understand how to get it from script code.
Thanks.
When in doubt, go to the source
use setFetchSource(String[] includes, String[] excludes) instead
use setFetchSource(false) instead
if you need to execute this script for each document, you can use addScriptField()
i update the opengl version.
But i got an error :
AWTGLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl,
AWTGLPixelBuffer.awtPixelAttributesIntRGB3,
v.getWidth(),
v.getHeight(),
1,
true,
0);
My library could not find awtPixelAttributesIntRGB3 . If i use old version, it can find that.
I import the same library : import com.jogamp.opengl.util.awt.AWTGLPixelBuffer;
Last thing, i downloaded last version of opengl here (jogamp-all-platforms.7z) :
http://jogamp.org/deployment/jogamp-current/archive/
And i only add jogamp-all.jar to my lib folder.
Thanks in advice.
You give us very little information on what's going on.
E.g. we don't even know from what version to which new one you upgraded.
I guess your problem is that the field awtPixelAttributesIntRGB3 was removed from version 2.2 to 2.3.
The API documentation of GLPixelBuffer.GLPixelBufferProvider#allocate explains quite well how to use it.
The key is that you need to fetch pixelAttributes differently, e.g. via getAttributes(GL, int, boolean).
I am making a call from a server that is located in US to FindItemsAdvanced of ebay finding api.
I define ListedIn as "EBAY-ENCA", however, when I make the call - I see that it doesn't return results. I believe that this is because that items are not available to US.
I see that there is a parameter called: AvailableTo - but how can I say "to all countries" ? Writing each iso code in the world could be exhausting..
My code:
ItemFilter marketFilter = new ItemFilter();
marketFilter.setName(ItemFilterType.LISTED_IN);
marketFilter.getValue().add("EBAY-ENCA");
request.getItemFilter().add(marketFilter);
ItemFilter conditionFilter = new ItemFilter();
conditionFilter.setName(ItemFilterType.AVAILABLE_TO);
conditionFilter.getValue().add("UK");
request.getItemFilter().add(conditionFilter);
In general this call should work - regardless from where you call the API. So I assume that you get an error message from the API that prevent items from being returned. Be aware that the FindItemsAdvanced call of the eBay Finding API requires either a given "categoryId" or a "keyword". Do you set any of these?
Here is the XML payload of a working call:
<findItemsAdvancedRequest xmlns="http://www.ebay.com/marketplace/search/v1/services">
<keywords>iPhone6</keywords>
<itemFilter>
<name>ListedIn</name>
<value>EBAY-ENCA</value>
</itemFilter>
</findItemsAdvancedRequest>
I've created an example in our API playground. It uses the XML version of the Finding API. Just execute the call to see the valid response with items included. You can adapt and customize the request parameters to your needs and see how the API responses.
The "AvailableTo" filter can only be used once per request with exactly one value. So it won't be possible to add it multiple times or to add it once with multiple values. But I'm not sure if I get your use case right. Do you really want to get only those items that are available world wide? If yes, then I'm afraid this most probably isn't possible without filtering them locally (eg. by filtering for "Worldwide" in the "shipToLocations").
I tried googling that's cause i am found 2 methods code.google.com/p/soundcloudapi-java/
in that step-1 occurred
java.lang.NoClassDefFoundError: oauth.signpost.commonshttp.CommonsHttpOAuthConsumer
i tried to found that solution but not got success anyone can help to sort out these bug......
am i trying to second one
github.com/soundcloud/java-api-wrapper so please suggest how to use it
Thanks in Advance...!!!!
i am including these library file...!!!
I found my mistake and how to integrate the sound-cloud SDK.
// Create a wrapper instance
ApiWrapper wrapper = new ApiWrapper("client_id", "client_secret", null, null, Env.LIVE);
Here, initialization of the ApiWrapper class pass old argument null at position of Env.LIVE* but in the new SDK it passes out Env.LIVE the parameter.