Category : nullpointerexception

I’m trying to create an application that can detect emotions through face, voice, and text. To do so, I created three buttons that will direct to the specific Activities. I’m using Azure Cognitive service to detect the face. but my app keeps crashing whenever I clicked on the first button "face" instead of opening the ..

Read more

When I try to close my GATT connection, I do the following: BluetoothGatt gatt; … private void disconnectDevice() { … if (this.gatt != null) { this.gatt.disconnect(); this.gatt.close(); this.gatt = null; } … } However, the app crashes with a NullPointerException in the this.gatt.close(); line (not in the disconnect() line) on my Samsung Galaxy S4 mini. ..

Read more

My question is simple. I do have nullcheck for context and activity but when i’ve checked on crashlytics there is a crash for this method. How can i prevent it ? public void continueWithDashboard() { if (getActivity() == null || getContext() == null) { Log.e(TAG, "continueWithDashboard: activity null"); return; } getActivity().startActivity(new Intent(getActivity(), DashboardActivity.class)); getActivity().finish(); } ..

Read more

Hi Please help me to resolve this issue I m getting this error message. The app crashes I have tried almost every solution suggested on Google I am creating a Notes application for Android and the logic of the app when it starts is to check if there is a user created and logged in ..

Read more

I’m trying to call MainActivity.my_method() from a different class, but I get: java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String android.content.Context.getPackageName()’ on a null object reference MainActivity.java public class MainActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); my_method(); //WORKS WELL } public void my_method() { startActivity( new Intent( Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Uri.parse( "package:" + getPackageName() ) ..

Read more

I have made several recyclerViews so far, but I faced new error this time,, In onBind method in ViewHolder Class, every line returns NullPointerException. I read Logcat and I think this exception is from Views in onBind method(TextView, etc..). Can anyone find what’s the problem? The code below is adapter class:) package com.example.ctrl_c; import … ..

Read more

I’m building apk from an android project exported from Cocos Creator V2.4.3 but getting the below error with Gradle A problem occurred configuring project ‘:game’. > java.lang.NullPointerException (no error message) I’ve deleted all android SDK, NDK and re-installed Android Studio, then re-update SDK, NDK, Build Tool. But the error still occurs. Some configurations: Android SDK ..

Read more

I want to set a carusel adapter in a fragment. I use in XML <androidx.viewpager.widget.ViewPager android:id="@+id/viewPager" android:layout_width="match_parent" android:layout_height="190dp" android:layout_marginBottom="8dp"/> and in Kotlin: override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { val viewPagerAdapter = ViewPagerAdapter(activity) viewPager!!.adapter = viewPagerAdapter // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_login, container, false) } Unfortunately I ..

Read more