Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Crash on Samsung S5 running Android 6.0.1 #10

Open
medavox opened this issue Jun 18, 2019 · 1 comment
Open

Crash on Samsung S5 running Android 6.0.1 #10

medavox opened this issue Jun 18, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@medavox
Copy link
Collaborator

medavox commented Jun 18, 2019

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.github.palmcalc2019.palmcalc/com.github.palmcalc2019.palmcalc.PalmCalcActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
	at com.github.palmcalc2019.unit.AbstractWheelTextAdapter.<init>(AbstractWheelTextAdapter.java:75)
	at com.github.palmcalc2019.unit.AbstractWheelTextAdapter.<init>(AbstractWheelTextAdapter.java:65)
	at com.github.palmcalc2019.unit.AbstractWheelTextAdapter.<init>(AbstractWheelTextAdapter.java:60)
	at com.github.palmcalc2019.unit.ArrayWheelAdapter.<init>(ArrayWheelAdapter.java:43)
	at com.github.palmcalc2019.unit.AndroidQAActivity.IntwheelSelector(AndroidQAActivity.java:434)
	at com.github.palmcalc2019.unit.AndroidQAActivity.onStart(AndroidQAActivity.java:124)
@medavox medavox changed the title Crash on Samsun S5 running Android 6.0.1 Crash on Samsung S5 running Android 6.0.1 Jun 18, 2019
@medavox medavox added the bug Something isn't working label Jun 18, 2019
@medavox
Copy link
Collaborator Author

medavox commented Jun 18, 2019

caused by passing global static Context object to a new class instance.

The value of the ctx variable is old, from the last program run.

So when this is passed to a new ArrayWheelAdapter instance, which tries to use it to get a layout inflater, the context being used is null, and an NPE is caused.

key method (was AndroidQAActivity.java:434, now somewhere in ConverterFragment):

private void IntwheelSelector(int id, String[] change) {
//...
		wheel.setViewAdapter(new ArrayWheelAdapter(ctx, change));
//...
	}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant