Example usage for java.lang NullPointerException printStackTrace

List of usage examples for java.lang NullPointerException printStackTrace

Introduction

In this page you can find the example usage for java.lang NullPointerException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.google.android.gms.location.sample.locationupdates.MainActivity.java

/**
 * Updates the latitude, the longitude, and the last location time in the UI.
 *//*  www  . j  a va 2  s  .c o  m*/
private void updateUI() {
    try {
        mLatitudeTextView.setText(String.format("%s: %f", mLatitudeLabel, mCurrentLocation.getLatitude()));
        mLongitudeTextView.setText(String.format("%s: %f", mLongitudeLabel, mCurrentLocation.getLongitude()));

        mLastUpdateTime = DateFormat.getTimeInstance().format(new Date());
        mLastUpdateTimeTextView.setText(String.format("%s: %s", mLastUpdateTimeLabel, mLastUpdateTime));

        PostInformation(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude(),
                String.format("%s", mLastUpdateTime));
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:com.example.xusoku.dragtopviewdemo.DragTopLayout.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    try {/*from   ww w . j  av  a  2  s.  c  o  m*/

        boolean intercept = shouldIntercept && dragHelper.shouldInterceptTouchEvent(ev);
        Log.e("intercept", "shouldIntercept=" + shouldIntercept + "  intercept=" + intercept);
        return intercept;
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:com.futureinst.widget.dragtop.DragTopLayout.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    try {/*from ww w .  java2s .  co m*/

        boolean intercept = shouldIntercept && dragHelper.shouldInterceptTouchEvent(ev);
        return intercept;
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);

    isCenterOnMyLocation = false;// ww w  .j  a va2 s.c o m

    if (getIntent().hasExtra(Const.INTENT_EXTRA_POST_ID)) {
        try {
            final ActionBar ab = getSupportActionBar();
            if (ab.getSelectedTab().getPosition() != Const.TABS_INDEX_MAP) {
                ab.setSelectedNavigationItem(Const.TABS_INDEX_MAP);
            }
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    } else if ((savedInstanceState != null)
            && (savedInstanceState.containsKey(Const.KEY_BUNDLE_SELECTED_TAB))) {
        if (savedInstanceState.getString(Const.KEY_BUNDLE_SELECTED_TAB).equals(Const.TAG_TABS_FAVORITES)) {
            try {
                final ActionBar ab = getSupportActionBar();
                if (ab.getSelectedTab().getPosition() != Const.TABS_INDEX_FAVORITES) {
                    ab.setSelectedNavigationItem(Const.TABS_INDEX_FAVORITES);
                }
            } catch (NullPointerException e) {
                e.printStackTrace();
            }
        }
    }

}

From source file:opendial.gui.utils.StateViewer.java

/**
 * Quick fix for a strange bung in JUNG/*from  ww w .  j  ava 2s.  co m*/
 */
@Override
public void paintComponent(Graphics g) {
    try {
        super.paintComponent(g);
    } catch (NullPointerException e) {
        log.fine("cannot repaint state viewer, waiting for next update: ");
        e.printStackTrace();
        isUpdating = false;
        // tab.trigger(currentState, currentState.getChanceNodeIds());
    }

}

From source file:org.ale.openwatch.feeds.RemoteRecordingsListFragment.java

private void fetchFeedPage(int page) {
    if (!fetching_next_page) {
        if (Constants.isOWFeedTypeGeoSensitive(feed) && device_location != null) {
            try {
                OWServiceRequests.getGeoFeed(this.getActivity().getApplicationContext(), device_location, feed,
                        page, cb); // NPE HERE
                fetching_next_page = true;
                showLoadingMore(true);//from  www  .j a  va2 s. c  om
            } catch (NullPointerException e) {
                Log.e(TAG, "NPE getting GeoFeed");
                e.printStackTrace();
            }
        } else {
            try {
                OWServiceRequests.getFeed(this.getActivity().getApplicationContext(), feed, page, cb);
                fetching_next_page = true;
                showLoadingMore(true);
            } catch (NullPointerException e) {
                Log.e(TAG, "NPE getting GeoFeed");
                e.printStackTrace();
            }
        }
    }
}

From source file:be.ehb.restservermetdatabase.webservice.AchievementController.java

public String getImg(String url) {
    BufferedImage img = null;/*from  w  ww  .j av a2s .com*/
    File f = null;
    try {
        f = new File(url);
    } catch (NullPointerException e) {
        f = new File("unnamed.png");
    }
    try {
        img = ImageIO.read(f);
    } catch (IOException e) {
    }
    String imageString = null;
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", bos);
        byte[] imageBytes = bos.toByteArray();
        imageString = new sun.misc.BASE64Encoder().encode(imageBytes);
        bos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return imageString;
}

From source file:com.zzmstring.viewset.View.DragTopLayout.DragTopLayout.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {

    try {// w  w w.  j a  v a 2  s.  c o m

        boolean intercept = shouldIntercept && dragHelper.shouldInterceptTouchEvent(ev);
        return intercept;
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java

@Override
public void onResume() {
    super.onResume();

    // Check Playservices status
    if (isPlayservicesOutdated) {
        if (GooglePlayServicesUtil
                .isGooglePlayServicesAvailable(getApplicationContext()) != ConnectionResult.SUCCESS) {
            // Still out of date, interrupt onResume()
            disableLocationUpdates();//from w ww .j  a v a  2 s . c  om
        } else {
            // Playservice updated, display message and restart activity
            parkingApp.showToastText(R.string.toast_playservices_restart, Toast.LENGTH_LONG);
            final Intent intent = getIntent();
            this.finish();
            startActivity(intent);
        }
        return;
    }

    if (!ConnectionHelper.hasConnection(this)) {
        ConnectionHelper.showDialogNoConnection(this);
    }

    // TODO Optimize this using savedInstanceState to avoid reload of
    // identical data onResume
    final Intent intent = getIntent();
    if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        updateParkingTimeFromUri(intent.getData());

        updateParkingTimeTitle();
        updateParkingDateButton();
        updateParkingTimeButton();
        updateParkingDurationButton();
        mFavoritesFragment.refreshList();
    }

    // if
    // (getSupportActionBar().getSelectedTab().getTag().equals(Const.TAG_TABS_MAP)
    // || isCenterOnMyLocation) {
    if (initLocation != null || isCenterOnMyLocation) {
        try {
            mMapFragment.setMapCenter(initLocation);
            isCenterOnMyLocation = false;

            final ActionBar ab = getSupportActionBar();
            if (ab.getSelectedTab().getPosition() != Const.TABS_INDEX_MAP) {
                ab.setSelectedNavigationItem(Const.TABS_INDEX_MAP);
            }
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    }
    // }

}

From source file:com.filemanager.free.activities.TextReader.java

@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

    // clearing before adding new values
    if (searchEditText != null && charSequence.hashCode() == searchEditText.getText().hashCode()) {
        try {//from w w w . ja  va2 s.c  o m
            if (searchTextTask != null)
                searchTextTask.cancel(true);

            nodes.clear();
            mCurrent = -1;
            mLine = 0;

            Thread clearSpans = new Thread(this);
            clearSpans.run();
        } catch (NullPointerException e) {
            e.printStackTrace();
        }

    }
}