Tag: null

getActionBar() returns null after SDK update to 5.0

After I updated the Android SDK to version 5.0 the getActionBar() method started to return null causing my app to crash on launch. I am clueless to what’s causing this and any existing Stackoverflow threads didn’t help. Here is my manifest: <application android:name=”App” android:allowBackup=”true” android:icon=”@drawable/ic_launcher” android:label=”@string/app_name” android:theme=”@style/ActionBarTheme” > styles.xml: <style name=”AppBaseTheme” parent=”Theme.AppCompat.Light”></style> <!– Application theme. […]

Java vs Objective C in case of nullpointer exception

Why does Java frequently throw null pointer exception if I try to access null values while Objective C does not? Java: public class SubscribeEmailActivity { String status; public static void main(String[] args){ if(Status.equals(null)||status.equals(“”){ // i am getting error here } } } Objective C: //in .h file NSString *exp; //in .m file if ([exp isEqualToString:NULL] […]

ArrayList automatically adding null items

Hello everyone. I’m making a vocabulary App, in which I need to create a List<String> (or ArrayList). To do so, I’ve created the following piece of code (just an example): List<String> tempSOLUTION = new ArrayList<String>(); String temp = “abc123”; tempSOLUTION.add(temp); I’ve also tried the following: tempSOLUTION.add(new String(temp)); Both of them add the item to the […]

EditText.getText().toString() sometimes returns “”

I get EditText’s text and its length in onTextChanged() method of TextWatcher. It works fine when I type to add characters, but while removing characters from text getText() gives empty even if text is not empty. This occurs randomly and not everytime I remove characters. I have observed this happens mostly when 3-4 characters are […]

App crashes when run from phone but works fine when launched from computer

I’ve been able after 3 days of work to make an old app run on my device! But only when the command comes from my computer… I explain. When I launch the app from Android Studio on my phone, it launches fine, which is great. But when I launch it directly from my phone, I […]

How can we define null as a datatype in Android, like we define nsNull in iPhone

jsonObject.accumulate(“status”,null); I want to pass null as a value in json service call i try “”,” “, NULL, nil,”null” but nothing helps Could anyone have solution for this ?

How do I ensure another Thread's Handler is not null before calling it?

My program threw a NullPointerException the other day when it tried to use a Handler created on another thread to send that thread a message. The Handler created by the other thread was not yet created, or not yet visible to the calling thread, despite the calling thread having already called start on the other […]

Testing for null JSON Objects in Java/Android

I am getting this LogCat: 06-22 15:30:53.731: E/AndroidRuntime(2389): java.lang.NumberFormatException: Invalid float: “null” 06-22 15:30:53.731: E/AndroidRuntime(2389): at java.lang.StringToReal.invalidReal(StringToReal.java:63) 06-22 15:30:53.731: E/AndroidRuntime(2389): at java.lang.StringToReal.parseFloat(StringToReal.java:310) 06-22 15:30:53.731: E/AndroidRuntime(2389): at java.lang.Float.parseFloat(Float.java:300) 06-22 15:30:53.731: E/AndroidRuntime(2389): at java.lang.Float.valueOf(Float.java:337) Here is code: try { jObject = new JSONObject(result); starAvg = jObject.getString(“AverageRating”); } ratingsBar = (RatingBar) findViewById(R.id.theRatingBar); ratingsBar.setRating(Float.valueOf(starAvg)); Here is the context: In […]

Volley string request error while passing string with null value as param

I am using the following code for string request on volley pDialog = new ProgressDialog(context); pDialog.setMessage(“Loading…”); pDialog.setCancelable(false); pDialog.show(); StringRequest strReq = new StringRequest(Method.POST, url, new Response.Listener<String>() { @Override public void onResponse(String response) { pDialog.dismiss(); Log.e(tag, response); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { pDialog.dismiss(); } }) { protected Map<String, String> getParams(){ […]

GCM returns a null message type

I created an application that uses GoogleCloudMessaging. Application can register to the gcm and store its registration id to the database at my server. I am using php, for sending push notifications but when the google sends it to my device, the intent service finds its message type to be null. I have tried the […]

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