Buggy code:
public class RunningProgramsRemoteViewsService extends RemoteViewsService { @ Override public RemoteViewsFactory onGetViewFactory ( Intent intent ) { } class RunningProgramsRemoteViewsFactory implements RemoteViewsFactory { private Context mContext ; private Cursor mCursor ; private int mAppWidgetId ; private int mIdIndex ; private int mStartTimeIndex ; private int mEndTimeIndex ; private int mTitleIndex ; private int mChannelNameIndex ; private int mOrderNumberIndex ; private int mLogoIndex ; private int mEpisodeIndex ; private int mCategoryIndex ; private int mMarkingPluginsIndex ; private int mMarkingFavoriteIndex ; private int mMarkingReminderIndex ; private int mMarkingFavoriteReminderIndex ; private int mMarkingSyncIndex ; private int mVerticalPadding ; private boolean mShowChannelName ; private boolean mShowChannelLogo ; private boolean mShowBigChannelLogo ; private boolean mShowEpisode ; private boolean mShowCategories ; private boolean mShowMarkings ; private boolean mShowOrderNumber ; private boolean mChannelClickToProgramsList ; private float mTextScale ; private int [ ] mUserDefindedColorChannel ; private int [ ] mUserDefindedColorTime ; private int [ ] mUserDefindedColorTitel ; private int [ ] mUserDefindedColorCategoryDefault ; private int [ ] mUserDefindedColorEpisode ; private void executeQuery ( ) { } private void startAlarm ( ) { } private void removeAlarm ( ) { } public RunningProgramsRemoteViewsFactory ( Context context , Bundle extras ) { } @ Override public void onCreate ( ) { } @ Override public void onDataSetChanged ( ) { } @ Override public void onDestroy ( ) { } @ Override public int getCount ( ) { } @ Override public RemoteViews getViewAt ( int position ) { final RemoteViews rv = new RemoteViews ( mContext . getPackageName ( ) , layout . running_programs_widget_row ) ; <START_BUG> if ( ( mCursor . getCount ( ) ) > position ) { <END_BUG> mCursor . moveToPosition ( position ) ; final String id = mCursor . getString ( mIdIndex ) ; final long startTime = mCursor . getLong ( mStartTimeIndex ) ; final long endTime = mCursor . getLong ( mEndTimeIndex ) ; final CharSequence title = WidgetUtils . getColoredString ( mCursor . getString ( mTitleIndex ) , mUserDefindedColorTitel ) ; CharSequence name = mCursor . getString ( mChannelNameIndex ) ; final String shortName = SHORT_CHANNEL_NAMES . get ( name ) ; String number = null ; final CharSequence episodeTitle = ( ( mShowEpisode ) && ( ! ( mCursor . isNull ( mEpisodeIndex ) ) ) ) ? WidgetUtils . getColoredString ( mCursor . getString ( mEpisodeIndex ) , mUserDefindedColorEpisode ) : null ; Spannable categorySpan = ( ( mShowCategories ) && ( ! ( mCursor . isNull ( mCategoryIndex ) ) ) ) ? IOUtils . getInfoString ( mCursor . getInt ( mCategoryIndex ) , getResources ( ) , true , ( ( mUserDefindedColorCategoryDefault [ 0 ] ) == 1 ? Integer . valueOf ( mUserDefindedColorCategoryDefault [ 1 ] ) : null ) ) : null ; Spannable marking = WidgetUtils . getMarkings ( mContext , mCursor , mShowMarkings , mMarkingPluginsIndex , mMarkingFavoriteIndex , mMarkingReminderIndex , mMarkingFavoriteReminderIndex , mMarkingSyncIndex ) ; if ( shortName != null ) { name = shortName ; } if ( mShowOrderNumber ) { number = mCursor . getString ( mOrderNumberIndex ) ; if ( number == null ) { number = "0" ; } number += "." ; name = ( number + "<seq2seq4repair_space>" ) + name ; } Drawable logo = null ; int channelKey = mCursor . getInt ( mLogoIndex ) ; if ( mShowChannelLogo ) { if ( mShowBigChannelLogo ) { logo = MEDIUM_LOGO_MAP . get ( channelKey ) ; } else { logo = SMALL_LOGO_MAP . get ( channelKey ) ; } } final CharSequence time = WidgetUtils . getColoredString ( DateFormat . getTimeFormat ( mContext ) . format ( new Date ( startTime ) ) , mUserDefindedColorTime ) ; CompatUtils . setRemoteViewsPadding ( rv , running_programs_widget_row , 0 , mVerticalPadding , 0 , mVerticalPadding ) ; rv . setViewVisibility ( running_programs_widget_row_start_time , VISIBLE ) ; rv . setViewVisibility ( running_programs_widget_row_channel , VISIBLE ) ; if ( ( startTime <= ( System . currentTimeMillis ( ) ) ) && ( endTime > ( System . currentTimeMillis ( ) ) ) ) { final int length = ( ( int ) ( endTime - startTime ) ) // 60000 ; final int progress = ( ( int ) ( ( System . currentTimeMillis ( ) ) - startTime ) ) // 60000 ; rv . setProgressBar ( running_programs_widget_row_progress , length , progress , false ) ; rv . setViewVisibility ( running_programs_widget_row_progress , VISIBLE ) ; } else { rv . setViewVisibility ( running_programs_widget_row_progress , GONE ) ; } rv . setTextViewText ( running_programs_widget_row_start_time , time ) ; rv . setTextViewText ( running_programs_widget_row_title , ( marking != null ? TextUtils . concat ( title , marking ) : title ) ) ; if ( ( categorySpan != null ) && ( ( categorySpan . toString ( ) . trim ( ) . length ( ) ) > 0 ) ) { rv . setViewVisibility ( running_programs_widget_row_categories , VISIBLE ) ; rv . setTextViewText ( running_programs_widget_row_categories , categorySpan ) ; } else { rv . setViewVisibility ( running_programs_widget_row_categories , GONE ) ; } if ( ( mShowChannelName ) || ( logo == null ) ) { name = WidgetUtils . getColoredString ( name , mUserDefindedColorChannel ) ; rv . setTextViewText ( running_programs_widget_row_channel_name , name ) ; rv . setViewVisibility ( running_programs_widget_row_channel_name , VISIBLE ) ; } else if ( number != null ) { rv . setTextViewText ( running_programs_widget_row_channel_name , number ) ; rv . setViewVisibility ( running_programs_widget_row_channel_name , VISIBLE ) ; } else { rv . setViewVisibility ( running_programs_widget_row_channel_name , GONE ) ; } if ( ( logo != null ) && ( ( ( ( android . graphics . drawable . BitmapDrawable ) ( logo ) ) . getBitmap ( ) ) != null ) ) { rv . setImageViewBitmap ( running_programs_widget_row_channel_logo , ( ( android . graphics . drawable . BitmapDrawable ) ( logo ) ) . getBitmap ( ) ) ; rv . setViewVisibility ( running_programs_widget_row_channel_logo , VISIBLE ) ; }

Fix:
if ( ( ( ( mCursor ) != null ) && ( ! ( mCursor . isClosed ( ) ) ) ) && ( ( mCursor . getCount ( ) ) > position ) ) {