1. Error reporting
Attempt to invoke virtual method ‘android.view.Window android.app.Activity.getWindow()’ on a null object reference
2. Cause
VideoAdapter.java file code:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.item_mainlv,parent,false);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
}else {
holder = (ViewHolder) convertView.getTag();
}
// Get the data source of the specified location
String path = "xxxx";
holder.jzvdStd.setUp(path,"test",JzvdStd.SCREEN_NORMAL);
holder.jzvdStd.positionInList = position;
return convertView;
}
class ViewHolder{
JzvdStd jzvdStd;
public ViewHolder(View view){
jzvdStd = view.findViewById(R.id.item_main_jzvd);
}
}
Since jzvdStd has released the jzvdStd window when the full screen is cut to a small screen, and the subsequent if (convertView == null) judgment, directly to the else statement, so the window that has been released cannot be obtained by the statement in the else in the window, so the error is reported. (The above is a personal opinion)
3. Solution
Replace the above code with the following code
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (null == convertView) {
viewHolder = new ViewHolder();
LayoutInflater mInflater = LayoutInflater.from(context);
convertView = mInflater.inflate(R.layout.item_mainlv, null);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.jzvdStd = convertView.findViewById(R.id.item_main_jzvd);
// Get the data source of the specified location
String path = "xxx";
viewHolder.jzvdStd.setUp(path,"test",JzvdStd.SCREEN_NORMAL);
return convertView;
}
class ViewHolder{
JzvdStd jzvdStd;
}
Read More:
- How to Solve Error: Android java.lang.IllegalStateException: Could not execute method of the activity
- [Solved] Android9.0 App Install Android4.4 Error: InflateException-You must supply a layout_height attribute.
- Remember an android app startup error Error running: Default Activity not found
- [Solved] Android app development version update failed, Android – error: task execution failed ‘: app: com
- [Solved] Android 9.0 APP Install Android 4.4 Error: IllegalArgumentException
- Android Working Directory:NULL Environment:NULL Error
- [Solved] Android Project error: import android.support.v4 (V7). App.activitycompat
- [Solved] Manifest merger failed: android:exported needs to be explicitly specified for element <activity#com
- The SDK of Android webrtc compiled with Ninja – C out / release command reported an error, and the Android NDK processing method could not be found
- Android7.0+ Failed to Share Images: exposed beyond app through ClipData.Item.getUri()
- [Solved] Failed to invoke @ExceptionHandler method is reported after adding @ControllerAdvice
- Download and save uniapp pictures to Android error reporting app
- [Solved] Android Studio Start Error: Missing essential plugin: org.jetbrains.android Please reinstall Android
- [Solved] conda activates the virtual environment error: Invoke-Expression
- How to Solve Android Studio run main() Method Error
- [Solved] Android Studio Compile Error: Execution failed for task ‘:APP_MIDI:lintVitalRelease‘.
- Android studio Error:Execution failed for task ‘: app:transformResourcesWithMergeJavaResForDebug ‘
- [Solved] Android Studio Error: error while launching activity
- [Solved] Android Error: Execution failed for task ‘:app:mergeReleaseNativeLibs‘.
- [Solved] Android Studio Error:This view is not constrained, it only has designtime positions