nullpointerexception

NullPointerException with Fragment Interface Listener

三世轮回 提交于 2019-12-25 03:25:16
问题 I'm sorry, I'm sure that this will be simple but I just cannot see where I'm going wrong here. I've got a Fragment (a tool list) that can start a number of other fragments (tools) in a two pane set up. There is an activity that sits above & I am using it to manage the removal of tool fragments when their 'close button' is pressed. It then pops a tool from the backstack if one exists. The strange thing is, that I have this working within one fragment but the 'cut & pasted' code into another

How to get a Call state of a phone [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-12-25 03:13:52
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Trouble with reading phone state I want to get a call state of phone in my application. I am doing one application in which , When user dial to a number, then my application should come to know whether other side phone is Busy, Not-reachable or power-off states etc. For this I used com.android.internal API's they are Call.java <http://hi-android.info/src/com/android/internal/telephony/Call.java.html> ,

Strange nullpointer exception error when i use a List

杀马特。学长 韩版系。学妹 提交于 2019-12-25 03:13:23
问题 i am using a List of <Friend> , Friend is a class that i have with some info about a person, name, desc, etc... ok, this is the code on the start of the class: private List<Friend> friends; and later... in a method of the class: Friend a = new Friend("Pablo SáeZ", "Total", "39.68333", "-0.32667", new Date()); friends.add(a); ok, i have the nullpointerexception on the line friends.add(a); can someone explain why? thanks 回答1: Because you haven't initialized friends yet. It's still null . You

Spring 3.1 Dependency Injection - JUnit Testing

六眼飞鱼酱① 提交于 2019-12-25 03:07:09
问题 I'm using Spring MVC 3.1 and I am attempting to test a controller class called LoginController. I get a null pointer exception in the authenticate method when the method attempts to make a call using reference authenticationService, which is Autowired in the LoginController class. I have referenced this link as well as this one . Please see code below for clarity LoginControllerTest.java @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:servlet-context.xml"

JavaScript ScriptEngine isn't working within Google App Engine for Java (GAE/J)

喜夏-厌秋 提交于 2019-12-25 02:53:52
问题 I am having an issue where I always get a 0 value returned when I try to use the ScriptEngine eval. By using Logger, I was able to determine that there are NullPointerExceptions being generated. After further inspection, it appears that GAE doesn't always return a valid script engine (if ever), because it throws an exception when you try to use it. My code looks like: public double myEval(String JsFormulaStr ) { double solutionValue = 0; ScriptEngineManager mgr = new ScriptEngineManager();

NullPointerException with inherited function from a class

牧云@^-^@ 提交于 2019-12-25 02:52:23
问题 I am trying to inherit a function from a class, but it returns NullPointerException . Can anyone please help? This is the function I try to inherit in Main.java . This function operates well in Main.java . public void readData() { String readString = ""; try { FileInputStream fIn = openFileInput("user.txt"); InputStreamReader isr = new InputStreamReader(fIn); BufferedReader buffreader = new BufferedReader(isr); readString = buffreader.readLine(); isr.close(); } catch (IOException ioe) { ioe

create android geofence in background without crashing

喜夏-厌秋 提交于 2019-12-25 02:45:14
问题 I currently have an IntentService that receives gcm messages with lat,lng infos and I would like to register a geofence in the background without a foreground app. I already tried putting the working (in an activity) code into the IntentService but I get a nullpointerexception and I have no idea why. @Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm

FATAL EXCEPTION: main Unable to start activity ComponentInfo Caused by: java.lang.NullPointerException

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 02:42:36
问题 ERROR: FATAL EXCEPTION: main Unable to start activity ComponentInfo Caused by: `java.lang.NullPointerException` I'm not sure exactly why this is happening. It is crashing app on the line: listView.setOnVideoClickListener((VideoClickListener) this); I have my listview declared in my XML and my Java - so I'm not sure exactly what has gone wrong at this point LOGCAT: 12-04 15:37:10.563: E/AndroidRuntime(9470): FATAL EXCEPTION: main 12-04 15:37:10.563: E/AndroidRuntime(9470): java.lang

Null Pointer exception on layout inflator

本小妞迷上赌 提交于 2019-12-25 02:25:41
问题 I am trying to add listview to my layout from a class which extends fragments. The problem is, when the data is coming, the layout is showing null pointer exception. Here is the code: TopStoriesFragment.java public class TopStoriesFragment extends Fragment { public String thehindu = "http://www.thehindu.com/news/?service=rss"; public String toi = "http://timesofindia.feedsportal.com/c/33039/f/533965/index.rss"; public String reuters = "http://feeds.reuters.com/reuters/topNews"; public String

An irrelevant NullPointerException during serialization [closed]

谁说胖子不能爱 提交于 2019-12-25 02:24:31
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I use serialization for saving the current state of my model to a file and load it maybe some minutes later. My application has nothing that deals JPA or similar technologies. It's a completely JavaSE desktop Swing Application. Serialization works quite well. Only I encountered that after the serialization the