priyanshi bhardwaj

Ranch Hand
+ Follow
since Mar 29, 2017
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by priyanshi bhardwaj

Tim Moores wrote:
Where did you get the idea that shorter code is better code?

No where.Actually I want to handles errors and log's in my code.These are just dummy number of errors which I have stated.The errors can go upto from 1....250 also.What if I want to add more errors after few months also.So I want to write a code which is scalable as well as less hard coded so that it's easier for me to handle errors in future also.That is the main reason I am trying to avoid if and when statements writing it for 250 errors is quite almost impossible.
I simply want a class where I will define error code with string which needs to be printed for my user. And a function which will map my error code.
6 days ago

Tim Moores wrote:The proper question is not "can you use reflection", the proper question is "does it make sense". You can use all kinds of approaches to all kinds of problems, but that may not be a good idea. In this case, I don't see what benefit using reflection would have over the approaches Mike mentioned; so you should avoid it.

using when or if statements will increase number of hard coded lines.I want to avoid it.
1 week ago

Mike Simmons wrote:Liutaras is pointing in the right direction.  I would be inclined to use a when statement (Kotlin's version of switch):

or a Map:

Can I not use reflection library.was reading this :
1 week ago
Hi I am trying to access nested class variables how can I access it.

I want the output as "INVALID".
Currently I am getting "E400" I want to return the variable value of E400 ("INVALID").

What I want from code is I call a function with 400 as variable.And I want "Invalid" as output.
If I pass 401 I want "Unauthorised" as output.Or any other simple way of doing it.
I am new with kotlin so unable to do it.
1 week ago

Swastik Dey wrote:what is the value or url variable?

Thanks for replying it's solved now. Solution to my problem was I have enabled Javascript in web-view due to which it was redirecting it to new page .Disabling it ended up stoping of my redirection.
2 weeks ago
Hi EveryOne,
I am trying to use webview in my android app in which URL of Webview I am handleing using INTENT but when Url is getting loaded .It get's loaded for few seconds and then webpage not found error comes.Any Solution for this.
This is my handle Intent function

This is my onCreate Function

Error is as follow

description: net::ERR_UNKNOWN_URL_SCHEME

2 weeks ago
Thanks!! It is resolved now.
4 weeks ago

Ron McLeod wrote:
try {
           JSONArray jsonArray=new JSONArray(responseBody);
       }catch (JSONException e){

How can I convert response.body() to string because response.body.string is no longer in use .
4 weeks ago

Ron McLeod wrote:Please post the entire stack trace,

Stack Trace is for this particular code

And How can I check JSON VERSION?
4 weeks ago

Ron McLeod wrote:Try writing response.body() to the log to verify that you are working with a properly formatted JSON payload.

Already done that JSON is properly formatted.
4 weeks ago

Ron McLeod wrote:Your JSON message has errors.  The are missing " symbols for the country field values.

Still getting same message
4 weeks ago

Adrian Grabowski wrote:I use org.json for this, it has JSONArray which does exactly what you want.

Already done this it is throwing error

org.json.JSONException: Not a primitive array: class java.util.ArrayList

4 weeks ago

Matthew Keller wrote:I am having trouble telling if you are receiving this json on the server or in the browser.  In the browser you can use eval() to turn the json into an object, then access it by using dot and array notation.

I am receiving this data in my java file(client side) of my android and then I will be pushing it into my db and fetch that data from it and display it in my xml.
4 weeks ago
Hi,I am trying to map a response body from an api and use that response body in my app.My API returns an array of Objects.I am using retrofit to use this response body.Still not able to use it.
  I want to deserialise this data How can I do this?
1 month ago