nullpointerexception

Why is NPE thrown when finishing Activity?

可紊 提交于 2019-12-14 01:05:28
问题 I have an error that has been driving me crazy for days. Unfortunately, I can not show you the code for two reason, my boss will not appreciate it and the codebase is too large to share. The error occurs whenever the Activity is finishing. Weather it be because I call finish() or because the os destroys it. The question is, what is (or could) cause execPendingActions() in FragmentManagerImpl to throw a NPE at line 1196. Here is the stacktrace: FragmentManagerImpl.execPendingActions() line:

Android : Update Tab Layout(fragments) textviews from an activity

青春壹個敷衍的年華 提交于 2019-12-13 23:17:54
问题 I'm creating tab view using tablayout and viewpager. I use one fragment for each tab. And in my MainActivity, I'm getting some values from a device through bluetooth. The values are received as a single string, and I split it and sets it to corresponding tabs. But I'm getting a NullPointerException when I try to call the setText method for the textview in fragment from my activity. Can anybody show me how to update the textviews of each of the fragments from my MainActivity?? Like, if i

Save String (Cookie) to SharedPrefs caused NullPointerException

柔情痞子 提交于 2019-12-13 23:09:36
问题 I´ve made a class with helps me to handle the Authentication (save Cookie to SharedPrefs). public class Authentication extends Application { String PREFS_NAME = "UserData"; String DEFAULT = ""; Context context; public static SharedPreferences sharedPreferences; public static SharedPreferences.Editor editor; public static String token; public Authentication(Activity context) { this.context = context; sharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); editor =

Do something when app starts?

情到浓时终转凉″ 提交于 2019-12-13 22:28:50
问题 I have a very quick question. Whenever the user downloads my app, for some reason the volume is at zero. I want to raise the volume whenever the user enters the app for the first time, and update something. Whenever the app is created, I want the users volume to be increased, and the user can change that later. If the user leaves the app (home menu) and comes back, that code should not execute. So, I thought I would use the Application class: That didn't work, since to do the update I

NullPointerException Android [duplicate]

北城以北 提交于 2019-12-13 22:22:53
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 3 years ago . I am getting NullPointerException and I couldn't fix it. Could anyone please have a look at my code to see what the problem is and how to fix it. Thanks in advance. DatabeseDEO.class public class DatabaseDEO { private DatabaseHelper DbHelper; public DatabaseDEO(Context context) { DbHelper = new DatabaseHelper(context); } public DatabaseDEO() { } public ArrayList

NPE thrown when trying to Find Button ID in Android Fragment

こ雲淡風輕ζ 提交于 2019-12-13 22:15:43
问题 This issue has persisted repeatedly no matter how many times I redo this. According to Android Developers, the ID to an object in the View Hierarchy of a fragment is obtained during onCreateView, and all of the questions I've pored over on here confirm this. However for some reason it ALWAYS returns null during the check I have setup and therefore I can not proceed to work with the buttons. The Fragment gets loaded during "decision events" in this project, and each event has different

null pointer exception error using action listener

百般思念 提交于 2019-12-13 22:11:54
问题 I'm getting the error message null pointer exception on the line img.setIcon(bg); in the controller class in my action listener and I'm not sure why. I've commented where the error is highlighted. Any ideas on why? public class Display { public ImageIcon bg; public JLabel img; public void UI() { Controller listener = new Controller(); bg = new ImageIcon("prophase.png"); img = new JLabel(bg, JLabel.CENTER); JFrame gameFrame = new JFrame(); JPanel top = new JPanel(); JPanel bottom = new JPanel(

NullPointerException when setImageDrawable and setImageResource in an ImageSwitcher

放肆的年华 提交于 2019-12-13 19:52:52
问题 I keep getting NullPointerException errors when I try to populate an ImageSwitcher with a resource. It is called using a WeakReference from within an AsyncTask , during the onPreExecute() : if (imageSwitcherReference != null) { ImageSwitcher imageSwitcher = imageSwitcherReference.get(); if (imageSwitcher != null) { imageSwitcher.setImageResource(R.drawable.receta_nofoto); } } Here's the pre stacktrace: 02-21 16:13:10.639: ERROR/AndroidRuntime(4274): java.lang.NullPointerException 02-21 16:13

Using button to change layout using Fragment

*爱你&永不变心* 提交于 2019-12-13 18:53:26
问题 So I'm trying to change my layout with a button using fragment, but I can't get it to work, probably because I don't really understand how it works. I'm very new to programming overall so I have a bit trouble understanding some stuff. Anyways, this is what I want to do. MainActivity public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FragmentManager fragmentManager = getFragmentManager();

Android Mystery NullPointerException getting last known location

倖福魔咒の 提交于 2019-12-13 18:23:21
问题 I'm getting a NullPointerException in one of my applications. I had thought I was accounting for all places in this piece of code for Null references, but it seems that I may have missed something. I've looked the code through and through, but I'm still not sure where this NullPointerException is being thrown from. This is an error reported by a user, so I can't debug, nor have I ever gotten this error while in development What's happening in the code/application: The user starts up the