List of usage examples for java.io OptionalDataException printStackTrace
public void printStackTrace()
From source file:it.mb.whatshare.PairOutboundActivity.java
/** * Returns the ID that the currently paired outbound device has given to * this device and must thus be included in messages sent to that device. * /* ww w .j a v a 2 s .c o m*/ * @param context * the current activity to access file with * @return the ID to be included in all messages sent to the currently * paired outbound device, <code>null</code> if no device is * currently paired in outbound */ static String getAssignedID(ContextWrapper context) { if (assignedID == null) { try { Pair<PairedDevice, String> paired = SendToGCMActivity.loadOutboundPairing(context); assignedID = paired.second; } catch (OptionalDataException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return assignedID; }
From source file:it.mb.whatshare.SendToGCMActivity.java
@Override protected void onNewIntent(final Intent intent) { tracker = GoogleAnalytics.getInstance(this).getDefaultTracker(); if (intent.hasExtra(Intent.EXTRA_TEXT)) { if (!Utils.isConnectedToTheInternet(this)) { Dialogs.noInternetConnection(this, R.string.no_internet_sending, true); } else {/*from w w w. j av a 2s. c o m*/ // send to paired device if any try { if (outboundDevice == null) { Pair<PairedDevice, String> paired = loadOutboundPairing(this); if (paired != null) outboundDevice = paired.first; } if (outboundDevice != null) { // share with other device shareViaGCM(intent); finish(); return; } } catch (OptionalDataException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // can't load paired device from file tracker.sendEvent("intent", "send_to_gcm", "no_paired_device", 0L); Dialogs.noPairedDevice(this); } } else { // user clicked on the notification notificationCounter.set(0); finish(); } }
From source file:it.mb.whatshare.PairOutboundActivity.java
private String getOutboundPaired() { try {// w w w .ja v a 2 s . c o m Pair<PairedDevice, String> paired = SendToGCMActivity.loadOutboundPairing(this); if (paired != null) { assignedID = paired.second; return paired.first.type; } } catch (OptionalDataException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // it's ok } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:com.amagi82.kerbalspaceapp.MissionPlanner.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mission_planner); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); getActionBar().setTitle(R.string.title_activity_mission_planner); if (savedInstanceState == null) { // Load saved missionData if available. try {/*from ww w. ja v a 2s.c o m*/ FileInputStream inStream = new FileInputStream( Environment.getExternalStorageDirectory() + File.separator + "MissionData"); ObjectInputStream objectInStream = new ObjectInputStream(inStream); int count = objectInStream.readInt(); for (int i = 0; i < count; i++) missionData.add((MissionData) objectInStream.readObject()); objectInStream.close(); } catch (OptionalDataException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // if the list is empty, add the default planet if (missionData.size() == 0) { missionData = setFirstMissionData(); } } else { missionData = savedInstanceState.getParcelableArrayList("key"); } mBackgroundContainer = (BackgroundContainer) findViewById(R.id.listViewBackground); mListView = (ListView) findViewById(R.id.list); tvTotalDeltaV = (TextView) findViewById(R.id.tvTotalDeltaV); mAdapter = new StableArrayAdapter(this, missionData, mTouchListener); // add the newDestination button as a footer below the listview ImageView newDestination = new ImageView(this); newDestination.setImageResource(R.drawable.ic_plus); mListView.addFooterView(newDestination); newDestination.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int possibleIconState = 0; // Lets MissionDestination know which icons it's allowed to use if (missionData.size() < 1) { possibleIconState = 1; } Intent intent = new Intent(MissionPlanner.this, MissionDestination.class); intent.putExtra("possibleIconState", possibleIconState); intent.putExtra("isNewItem", true); // Places the result as a new item in the listview startActivityForResult(intent, 0); } }); mListView.setAdapter(mAdapter); }
From source file:it.mb.whatshare.MainActivity.java
/** * Refreshes the layout of this activity, also reloading configured devices * from files.//from w ww. j av a 2 s. co m */ private void updateLayout() { if (outboundDevice == null) { try { Pair<PairedDevice, String> paired = SendToGCMActivity.loadOutboundPairing(this); if (paired != null) outboundDevice = paired.first; } catch (OptionalDataException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (FileNotFoundException e) { // it's ok } catch (IOException e) { e.printStackTrace(); } } final TextView outboundView = (TextView) findViewById(R.id.outbound_device); if (outboundDevice != null) { outboundView.setText(outboundDevice.type); } else { outboundView.setText(R.string.no_device); } final boolean outboundConfigured = outboundDevice != null; outboundView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { if (outboundConfigured) { Dialogs.confirmRemoveOutbound(outboundDevice, MainActivity.this); } else { showOutboundConfiguration(); } return true; } }); }