nullpointerexception

Getting unwanted NullPointerException in ternary operator - Why? [duplicate]

不想你离开。 提交于 2019-12-18 11:40:35
问题 This question already has answers here : Short form for Java If statement returns NullPointerException when one of the returned objects is null [duplicate] (3 answers) Closed last year . While executing the following code, I am getting a NullPointerException at line: value = condition ? getDouble() : 1.0; In earlier lines when I use null instead of getDouble() everything works and this is strange. public class Test { static Double getDouble() { return null; } public static void main(String[]

DialogFragment : NullPointerException (support library)

我的梦境 提交于 2019-12-18 11:24:52
问题 I'm using the excellent ACRA library to receive error reports from my apps. I'm receiving a lot of reports from customers concerning an NPE in DialogFragment, but Im unable to reproduce it : java.lang.NullPointerException at android.support.v4.app.DialogFragment.onActivityCreated(SourceFile:366) at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:892) at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1083) at android.support.v4.app.FragmentManagerImpl

ViewPager Fragments getting destroyed over time?

对着背影说爱祢 提交于 2019-12-18 10:24:33
问题 I am using Android's support.v4 package to develop a ViewPager containing multiple Fragment s. I am trying to hide the Views when the user changes page. So, I implemented an OnPageChangeListener to listen to my adapter, and call an update() method in my Fragment s when when a page change occurs. But I'm getting a NullPointerException , and I cannot figure out why. Here is the code: public class MyActivity extends FragmentActivity implements OnPageChangeListener { private static final int NUM

getting null pointer exception?

。_饼干妹妹 提交于 2019-12-18 09:47:35
问题 I am trying to have name of contacts in one array and their types in another array,but can't get through with null pointer exception.here is my code.I have pointed out the line where I am getting null pointer exception.please help..thanks in advance. package application.test; import android.app.Activity; import android.content.ContentResolver; import android.database.Cursor; import android.database.SQLException; import android.os.Bundle; import android.provider.ContactsContract; import

AndroidStudio Calendar.get(Calendar.DAY_OF_MONTH) nullPointer Exception

扶醉桌前 提交于 2019-12-18 09:46:12
问题 I have a problem with my calendar. Here is the code: Calendar mCalendar = Calendar.getInstance(); mToday[0] = mCalendar.get(Calendar.DAY_OF_MONTH); mToday[1] = mCalendar.get(Calendar.MONTH); // zero based mToday[2] = mCalendar.get(Calendar.YEAR); Can not run my project because AndroidStudio shows error on the Calendar.DAY_OF_MONTH , Calendar.MONTH etc... I get nullPointException while running in emulator It sais that Must be one of: java.util.Calendar.DAY_OF_MONTHjava.util.Calendar.MONTH etc.

What is a NullPointerException, and how do I fix it?

丶灬走出姿态 提交于 2019-12-18 09:39:40
问题 This post is a Community Wiki . Edit existing answers to improve this post. It is not currently accepting new answers. What are Null Pointer Exceptions ( java.lang.NullPointerException ) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? 回答1: When you declare a reference variable (i.e. an object) you are really creating a pointer to an object. Consider the following code where you

What is a NullPointerException, and how do I fix it?

本小妞迷上赌 提交于 2019-12-18 09:39:09
问题 This post is a Community Wiki . Edit existing answers to improve this post. It is not currently accepting new answers. What are Null Pointer Exceptions ( java.lang.NullPointerException ) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? 回答1: When you declare a reference variable (i.e. an object) you are really creating a pointer to an object. Consider the following code where you

Attempt to invoke virtual method 'android.view.View android.view.View.getRootView()' on a null object reference

前提是你 提交于 2019-12-18 09:35:15
问题 I am getting this error, "Attempt to invoke virtual method 'android.view.View android.view.View.getRootView()' on a null object reference" Here is my code. black.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View bView = findViewById(R.id.lin); View root = bView.getRootView(); root.setBackgroundColor(Color.parseColor("#000000")); } }); I have two views, one called overlay_view and the other activity_main. I am trying to change the color of overlay

NullPointerException in JPA

非 Y 不嫁゛ 提交于 2019-12-18 09:30:20
问题 I am creating a Java EE application using jpa. I am getting the following error when the code is run on server [2/25/12 22:56:31:371 IST] 00000047 SystemOut O hello [2/25/12 22:56:31:375 IST] 00000047 SystemOut O Error...:( [2/25/12 22:56:31:371 IST] 00000047 SystemErr R java.lang.NullPointerException [2/25/12 22:56:31:371 IST] 00000047 SystemErr R at plh.service.ejb.UserBean.getUserDetails(UserBean.java:41) [2/25/12 22:56:31:372 IST] 00000047 SystemErr R at sun.reflect

Force Close on Changing time: Time Picker (NPE)

为君一笑 提交于 2019-12-18 08:57:09
问题 When I click on the time picker for changing the time I get force close. Can anybody tell me where is the problem in my code. Android. and this is my code...... timePickerDateTimePickerPopup = (TimePicker) layoutDateTimePickerPopup.findViewById(R.id.timePicker_datetimepicker); timePickerDateTimePickerPopup.setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS); timePickerDateTimePickerPopup.setIs24HourView(true); timePickerDateTimePickerPopup.setCurrentHour(mCalendar.get(Calendar.HOUR