[Solved] Android java type org.json.JSONObject cannot be converted to JSONArray

Change JSONArray list = new JSONArray(Jo_result.getString(“result”)); To JSONObject list = new JSONObject(Jo_result.getString(“result”)); Your string is contained between {} which makes it an object. Keep in mind this {} = Json Object [] = Json Array UPDATE When you do this JSONObject resultsObject = list.getJSONObject(i); it’s expecting another object within the main object, for example : … Read more

[Solved] convert curl to httpclient post [closed]

The apache http client makes this a piece of cake. Check the following tutorial for more details : http://www.vogella.com/tutorials/ApacheHttpClient/article.html http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/ solved convert curl to httpclient post [closed]

[Solved] Okay so I’m coding a roll the dice game on java

In your for loop: Remove the semicolon (;) just after the for(int rolls= 1; rolls==trials; rolls++) line. Change: for(int rolls= 1; rolls==trials; rolls++) to: for(int rolls= 1; rolls<=trials; rolls++) As far as changing switch to if–else–if, not sure why you would want to do this, but simply write it as: if(face == 1){ one++; } … Read more

[Solved] how to use function correctly in java

thanks to all…..the thing which i dont know was – during a function call if i want to pass an array(arr[]) as argument then i just need to pass its name(arr) as argument not the square brackets([]) along with it. Here is my new optimized error free code which has been submitted successfully. import java.util.*; … Read more

[Solved] connecting to sql database in java [closed]

Problem is in your odbc connection goto ControlPanel->AdministrativeTools->DataSource(ODBC)->System DSN->ADD->SqlServer-> then in the name field give the Source Name. you have to use this name instead of testdb in your DriverManager.getConnection method. Because getConnectionMethod take the source name not the database name. so your code is not working. However after filling the source name fill the … Read more

[Solved] Using IF commands to Check if a button exists in Selenium Java [closed]

You may try this: public void ClickButton () throws InterruptedException { WebElement button = driver.findElement(By.id(“button”)); String Source = driver.getPageSource(); if (Source.contains(button)) { button.click(); Thread.sleep(3000); } else { driver.quit; } } Hope this can be helpful. Let me know if you are still facing problem. solved Using IF commands to Check if a button exists in … Read more

[Solved] Android Studio: App is crashing after running it on my smartphone [duplicate]

you have to write following in onCreate after setContentView() Button btnplus = (Button)findViewById(R.id.btnplus); RatingBar ratingbar = (RatingBar)findViewById(R.id.ratingBar); like below. public class MainActivity extends AppCompatActivity { Button btnplus; RatingBar ratingbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btnplus = (Button)findViewById(R.id.btnplus); ratingbar = (RatingBar)findViewById(R.id.ratingBar); } public void plusonclick() { if (ratingbar.getRating() == 1) { setContentView(R.layout.activity_plusrechnenlvl1); } … Read more

[Solved] how to make Edittext get bigger by animation after clicking on it

you need check focus on editText and set AnimatioValue edt.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View arg0, boolean hasfocus) { if (hasfocus) { Log.e(“TAG”, “edt focused”); //ValueAnimator total ValueAnimator valueAnimator = ValueAnimator.ofFloat(1f, 1.5f); valueAnimator.setDuration(325); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); edt.setScaleX(value); edt.setScaleY(value); edt.requestLayout(); } }); valueAnimator.start(); } else … Read more

[Solved] Get latitude and longitude from json data [closed]

Try with below code: JSONObject object = new JSONObject(YOUR RESPONSE STRING); JSONArray jArray = object.getJSONArray(“latlong”); for (int i = 0; i < jArray.length(); i++) { String lat = jArray.getJSONObject(i).getString(“lat”); String lon = jArray.getJSONObject(i).getString(“lon”); } 14 solved Get latitude and longitude from json data [closed]