nullpointerexception

Adapter for a spinner makes NullPointerException

巧了我就是萌 提交于 2019-12-25 06:38:46
问题 I made an array list in one of my value's folder, now when i want to adapt it to the spinner by retrieving it from the source folder it says NullPointerException : spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter adapter = ArrayAdapter.createFromResource(this,R.array.worker,android.R.layout.simple_list_item_1); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); Messages in LogCat: Caused by: android.content.res.Resources$NotFoundException: String array resource

Null pointer exception while writing to SourceDataLine

久未见 提交于 2019-12-25 06:24:37
问题 I have a byte array with audio samples. I want to play it, so I try to write it into SourceDataLine: SourceDataLine sample; private byte[] samplebytes; ... sample.start(); sample.write(samplebytes, 0, samplebytes.length); sample.drain(); sample.stop(); sample.close(); sample = null; And I get this: java.lang.NullPointerException at virtualcut.Sample.<init>(Sample.java:45) at virtualcut.model.SelectionModel.setPosition(SelectionModel.scala:79) at draggable.DraggableComponent$2.mouseReleased

Null Pointer Exception when posting a picture to Facebook wall (android)

无人久伴 提交于 2019-12-25 05:09:21
问题 My app is meant to allow users to take a picture and then upload it to their Facebook wall. The following code is very similar to many other examples of working code given on other SO questions pertaining to this exact same problem, yet still gives me the null pointer exception: private void postOnWall() { final String response = ""; try { Bundle params = new Bundle(); params.putString("message", getMessage()); params.putByteArray("picture", byteArray); mAsyncRunner.request(me/feed, params,

AnnotationActionValidatorManager - Caught exception while loading file java/lang/Object-validation.xml

微笑、不失礼 提交于 2019-12-25 04:44:15
问题 Struts version of our application is 2.3.8. Getting following exception after every post back to the server. Application is deployed on to WebSphere server. We don't have any validation xml in the project. ERROR com.opensymphony.xwork2.validator.AnnotationActionValidatorManager - Caught exception while loading file java/lang/Object-validation.xml java.lang.NullPointerException at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.loadFile(AnnotationActionValidatorManager.java

Attempt to invoke interface method 'int android.database.Cursor.getCount()' on a null object reference

主宰稳场 提交于 2019-12-25 04:29:12
问题 I do have a problem that gives me a headache. I store some images of my city in the sqlite database via a custom content provider. However when I run my app I get a null cursor. Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int android.database.Cursor.getCount()' on a null object reference at theo.testing.androidcustomloaders.fragments.MainActivityFragment.onActivityCreated(MainActivityFragment.java:74) at android.support.v4.app.Fragment.performActivityCreated

Display Media files in ListView, NullPointerException?

ぐ巨炮叔叔 提交于 2019-12-25 04:19:17
问题 MainActivity public class MainActivity extends Activity { /** Called when the activity is first created. */ private List<String> myList; File file; @Override public void onCreate(Bundle savedInstanceState) { Log.i("MEDIA", "A"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.i("MEDIA", "B"); ListView listView = (ListView) findViewById(R.id.listView1); myList = new ArrayList<String>(); Log.i("MEDIA", "C"); File directory = Environment

Getting a NullPointerException in my Swing Goose class

我是研究僧i 提交于 2019-12-25 03:58:06
问题 I think my _holder and/or _gooseAction is null .... Here are the relevant code/classes where _holder and _gooseAction are instantiated: Goose.java public class Goose { //Goose class private ActionHolder _holder; private gooseAction _gooseAction; public Goose (JPanel container, GooseAction action, ActionHolder holder) { super(container); _holder = holder; _gooseAction = _holder.getAction(); _gooseAction = action; } public void react() { _gooseAction.stop(); _holder.getAction(); _gooseAction =

Java: unary if - npe

筅森魡賤 提交于 2019-12-25 03:56:08
问题 Why does this code can cause a NPE? Findbugs give me the hint, that this can occur and it does sometimes :-) Any ideas? public Integer whyAnNPE() { return 1 == 2 ? 1 : 1 == 2 ? 1 : null; } 回答1: EDIT: The code in the question wasn't present when I wrote this answer. Here's another method to make it slightly clearer: public static Integer maybeCrash(boolean crash) { return true ? (crash ? null : 1) : 0; } The important point is that we have two conditional expressions here. The inner one is of

EditText.setText() Null Pointer Exception

≯℡__Kan透↙ 提交于 2019-12-25 03:55:15
问题 I have this NPE that is driving me crazy, maybe it's just "tunnel vision" but I can't solve it. I have a fragment inside an activity, and in the activity's onCreate() I instantiate fragment. Then later when the fragment is added to activity I call fragments method from the activity. The code is below transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.ActionInputFragment, settingsFragment).addToBackStack(null); transaction.commit(); if(jsonUserData != null)

Tabhost Null Pointer Exception

别来无恙 提交于 2019-12-25 03:53:38
问题 Can some one please assist me in this example of TabHost? The problem i have is, When I am trying to run the application I am getting Null Pointer Exception. Here is the code if some one need to have a look. public class TabBarExample extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); /** * TabHost will have Tabs **/ TabHost tabHost = (TabHost