Skip to content

Tag: android

How to transfer data from one activity to another in android

It might sound simple but I can’t make it working. I have two activities. Which first one is a form, and second one is showing data from a JSON file based on values entered in the first activity. So I am trying to make a simple version of it. I have a EditText, and a button, so when they press

android : Check EditText is null

i want to check and give condition to my edittext, if i input something to my edittext, l it will change my imageview, this is my code: i have problem here, my imageview not change…. is this code has true or not? Answer If I read your post correctly, you want to check if the EditText is ever empty as

Create and populate TreeMap in one line

Like an array new Integer[]{ 1, 2, 3 }, can I create and populate a TreeMap using just one line? Any chances for HashMap or LinkedHashMap too? Answer There is no built-in syntax for specifically initializing maps. However, you can take advantage of a special syntax known as “double brace initialization&…

Is it bad practice to keep data in static variables?

In an Android application, is it bad practice to store objects in static fields in these cases? Application data. Is it bad to keep application data in static variables in a class while the application is running? Currently, I’m storing the data in an instance variable in my Application class. Then clas…

How to exit a while loop after a certain time?

I have a while loop and I want it to exit after some time has elapsed. For example: Answer Thus the statement Checks if it has been 10 seconds or 10,000 milliseconds since the loop started. EDIT As @Julien pointed out, this may fail if your code block inside the while loop takes a lot of time.Thus using Execu…

WakefulBroadcastReceiver cannot be resolved to a type

My project shows error message that WakefulBroadcastReceiver cannot be resolved to a type. I looked up for all possible reasons I can think of. I have set android-support-library and google play services’s path. Even my mapView works (if I comment below code) that means google play service is correctly …