Tag: java

handler or timer android

i’m tryin’ to display a msg every 1 min!! non stop! i found exemple that display the msg just one time after a fixed delay!! can you help how can set it?? or if using timer is better how it works i need an exemple!! public class TimertestActivity extends Activity { /** Called when the […]

How to show progress bar until video play in live stream Android?

i am working on an application where i need to play video from a remote server as live stream. which is done by me successfully. i managed every thing in my app. but when video is loading i need to show a progress dialog over VideoView. i tried using OnPreparedListener as “how to show the […]

Android Support Library: getDrawable independent if vector or not

When working with Android >= 5.0, Drawable d = getResources().getDrawable(R.drawable.icon) Correctly parses the XML and returns a valid drawable. But when using the new Vector Drawable Support Library (Version 23.4, Gradle 2.1.2), this code crashes under Android 4. android.content.res.Resources$NotFoundException … Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag vector The solution would […]

How to call javascript from Android?

How do we call javascript from Android? I have this javascript library which I would like to use, I want to call the javascript function and pass the result value to the android java code. Haven’t found the answer from now. i managed to call android code from javascript, but I want the other way […]

Example of custom setDropDownViewResource spinner item

I would like to display two values in an drop down view of my spinner. Currently, it only has a city name, but I would also like to add a small distance field to it. MyCity<MyCityDistance> dataAdapter; dataAdapter = new MyCity(this, R.layout.mycityrow, list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); I have all the code for custom data adapter, exapanding my […]

How to force quit the Android app and restart it?

My Android app has a WebView that requires the Flash plugin. The webview will provide a Market link to Adobe Flash if it’s not installed. After installing Flash, the only way to instantiate it in my app is to force quit and restart the app. I would like to present a button to the user […]

How do I find all the Points in a Path in Android?

Awhile back I asked a question to see if I was able to find a pair of specific points in a path; however, this time I want to know if there is a way to know all points in a path? (I couldn’t find a method that did so, which is unfortunate because Java provides […]

append to file android

hey there, i need to append to my file but it is not working, it keeps overwriting the file, can anyone please tell me what is wrong: public void generateNoteOnSD(String sBody){ try { File root = new File(Environment.getExternalStorageDirectory(), “AdidasParticipants”); if (!root.exists()) { root.mkdirs(); } File gpxfile = new File(root, “participants.txt”); BufferedWriter bW; bW = new […]

Retrofit2 Android: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

I know this is not the first time someone asking about this problem but with Retrofit2 I can’t find the right solution to my problem. I followed a online tutorial and it worked just fine. When I applied same code to my own endpoint i get this exception: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at […]

Error: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

I got a problem with my android app. I got a button and and event associated , but when I click the first time an error appears “spans cannot have zero lenght”. . But when I click the second time, the event onclick runs well.. look at my java code: public class MainActivity extends Activity […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.