List of usage examples for java.lang IllegalStateException printStackTrace
public void printStackTrace()
From source file:edu.pdx.cecs.orcycle.UserInfoUploader.java
boolean uploadUserInfoV4() { boolean result = false; final String postUrl = mCtx.getResources().getString(R.string.post_url); try {/*w ww. j a v a2s. c o m*/ JSONArray userResponses = getUserResponsesJSON(); URL url = new URL(postUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); // Allow Inputs conn.setDoOutput(true); // Allow Outputs conn.setUseCaches(false); // Don't use a Cached Copy conn.setRequestMethod("POST"); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("ENCTYPE", "multipart/form-data"); conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); conn.setRequestProperty("Cycleatl-Protocol-Version", "4"); DataOutputStream dos = new DataOutputStream(conn.getOutputStream()); JSONObject jsonUser; if (null != (jsonUser = getUserJSON())) { try { String deviceId = userId; dos.writeBytes(fieldSep + ContentField("user") + jsonUser.toString() + "\r\n"); dos.writeBytes( fieldSep + ContentField("version") + String.valueOf(kSaveProtocolVersion4) + "\r\n"); dos.writeBytes(fieldSep + ContentField("device") + deviceId + "\r\n"); dos.writeBytes(fieldSep + ContentField("userResponses") + userResponses.toString() + "\r\n"); dos.writeBytes(fieldSep); dos.flush(); } catch (Exception ex) { Log.e(MODULE_TAG, ex.getMessage()); return false; } finally { dos.close(); } int serverResponseCode = conn.getResponseCode(); String serverResponseMessage = conn.getResponseMessage(); // JSONObject responseData = new JSONObject(serverResponseMessage); Log.v("Jason", "HTTP Response is : " + serverResponseMessage + ": " + serverResponseCode); if (serverResponseCode == 201 || serverResponseCode == 202) { // TODO: Record somehow that data was uploaded successfully result = true; } } else { result = false; } } catch (IllegalStateException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } catch (JSONException e) { e.printStackTrace(); return false; } return result; }
From source file:org.apache.cordova.media.AudioPlayer.java
/** * Start recording the specified file./* w w w. j a v a 2s .c om*/ * * @param file The name of the file */ public void startRecording(String file) { switch (this.mode) { case PLAY: Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode."); sendErrorStatus(MEDIA_ERR_ABORTED); break; case NONE: this.audioFile = file; this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC); this.recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); // THREE_GPP); this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); //AMR_NB); this.recorder.setOutputFile(this.tempFile); try { this.recorder.prepare(); this.recorder.start(); this.setState(STATE.MEDIA_RUNNING); return; } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } sendErrorStatus(MEDIA_ERR_ABORTED); break; case RECORD: Log.d(LOG_TAG, "AudioPlayer Error: Already recording."); sendErrorStatus(MEDIA_ERR_ABORTED); } }
From source file:org.kde.kdeconnect.UserInterface.DeviceFragment.java
void refreshUI() { //Log.e("DeviceFragment", "refreshUI"); if (device == null || rootView == null) { return;// ww w. ja va 2s.co m } //Once in-app, there is no point in keep displaying the notification if any device.hidePairingNotification(); mActivity.runOnUiThread(new Runnable() { @Override public void run() { if (device.isPairRequestedByPeer()) { ((TextView) rootView.findViewById(R.id.pair_message)).setText(R.string.pair_requested); rootView.findViewById(R.id.pair_progress).setVisibility(View.GONE); rootView.findViewById(R.id.pair_button).setVisibility(View.GONE); rootView.findViewById(R.id.pair_request).setVisibility(View.VISIBLE); } else { boolean paired = device.isPaired(); boolean reachable = device.isReachable(); boolean onData = NetworkHelper.isOnMobileNetwork(getContext()); rootView.findViewById(R.id.pairing_buttons).setVisibility(paired ? View.GONE : View.VISIBLE); rootView.findViewById(R.id.not_reachable_message) .setVisibility((paired && !reachable && !onData) ? View.VISIBLE : View.GONE); rootView.findViewById(R.id.on_data_message) .setVisibility((paired && !reachable && onData) ? View.VISIBLE : View.GONE); try { ArrayList<ListAdapter.Item> items = new ArrayList<>(); //Plugins button list final Collection<Plugin> plugins = device.getLoadedPlugins().values(); for (final Plugin p : plugins) { if (!p.hasMainActivity()) continue; if (p.displayInContextMenu()) continue; items.add(new PluginItem(p, new View.OnClickListener() { @Override public void onClick(View v) { p.startMainActivity(mActivity); } })); } //Failed plugins List final ConcurrentHashMap<String, Plugin> failed = device.getFailedPlugins(); if (!failed.isEmpty()) { if (errorHeader == null) { errorHeader = new TextView(mActivity); errorHeader.setPadding(0, ((int) (28 * getResources().getDisplayMetrics().density)), 0, ((int) (8 * getResources().getDisplayMetrics().density))); errorHeader.setOnClickListener(null); errorHeader.setOnLongClickListener(null); errorHeader.setText(getResources().getString(R.string.plugins_failed_to_load)); } items.add(new CustomItem(errorHeader)); for (Map.Entry<String, Plugin> entry : failed.entrySet()) { String pluginKey = entry.getKey(); final Plugin plugin = entry.getValue(); if (plugin == null) { items.add(new SmallEntryItem(pluginKey)); } else { items.add( new SmallEntryItem(plugin.getDisplayName(), new View.OnClickListener() { @Override public void onClick(View v) { plugin.getErrorDialog(mActivity).show(); } })); } } } ListView buttonsList = (ListView) rootView.findViewById(R.id.buttons_list); ListAdapter adapter = new ListAdapter(mActivity, items); buttonsList.setAdapter(adapter); mActivity.invalidateOptionsMenu(); } catch (IllegalStateException e) { e.printStackTrace(); //Ignore: The activity was closed while we were trying to update it } catch (ConcurrentModificationException e) { Log.e("DeviceActivity", "ConcurrentModificationException"); this.run(); //Try again } } } }); }
From source file:yunpeng.cordova.media.AudioPlayer.java
/** * Start recording the specified file./*from ww w . j a v a2 s .c o m*/ * * @param file The name of the file */ public void startRecording(String file) { switch (this.mode) { case PLAY: Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode."); sendErrorStatus(MEDIA_ERR_ABORTED); break; case NONE: this.audioFile = file; this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC); this.recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); // THREE_GPP); this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); //AMR_NB); this.recorder.setOutputFile(this.tempFile); try { this.recorder.prepare(); this.recorder.start(); this.setState(STATE.MEDIA_RUNNING); return; } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } sendErrorStatus(MEDIA_ERR_ABORTED); break; case RECORD: Log.d(LOG_TAG, "AudioPlayer Error: Already recording."); sendErrorStatus(MEDIA_ERR_ABORTED); } }
From source file:com.gaze.webpaser.StackWidgetService.java
private void getDatafromNetwork() { new AsyncTask<String, Void, String>() { @Override/* w w w . jav a 2 s . c o m*/ protected void onPreExecute() { super.onPreExecute(); onStartDataLoading(); } @Override protected String doInBackground(String... params) { ArrayList<NameValuePair> param = new ArrayList<NameValuePair>(); try { // Set up HTTP post // HttpClient is more then less deprecated. Need to change // to // URLConnection HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(listUrl); httpPost.setEntity(new UrlEncodedFormEntity(param)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); Log.i(LOG_TAG, "finish http"); // Read content & Log inputStream = httpEntity.getContent(); } catch (UnsupportedEncodingException e1) { Log.e("UnsupportedEncodingException", e1.toString()); e1.printStackTrace(); } catch (ClientProtocolException e2) { Log.e("ClientProtocolException", e2.toString()); e2.printStackTrace(); } catch (IllegalStateException e3) { Log.e("IllegalStateException", e3.toString()); e3.printStackTrace(); } catch (IOException e4) { Log.e("IOException", e4.toString()); e4.printStackTrace(); } // Convert response to string using String Builder try { BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"), 8); StringBuilder sBuilder = new StringBuilder(); String line = null; while ((line = bReader.readLine()) != null) { sBuilder.append(line + "\n"); } inputStream.close(); result = sBuilder.toString(); Log.i(LOG_TAG, "finish read stream: " + result); if (!isStreamTheTargetJson(result)) { result = ""; sBuilder.delete(0, sBuilder.length() - 1); } // parse json string here if (!result.isEmpty()) { if (result.startsWith("<html>")) return ""; JSONObject titleJson = new JSONObject(result); JSONArray datajson = titleJson.getJSONArray("data"); JSONArray urlQueue = datajson.getJSONArray(0); for (int i = 0; i < urlQueue.length(); i++) { JSONObject item = urlQueue.getJSONObject(i); String url = item.getString("link"); String introtext = item.getString("introtext"); String title = item.getString("title"); String images = item.getString("images"); String name = item.getString("name"); String time = item.getString("publish_up"); if (url != null) { // addToQueue(GlobalData.baseUrl+'/'+url); addToList(url, introtext, title, images, name, time); } } } } catch (Exception e) { Log.e("StringBuilding & BufferedReader", "Error converting result " + e.toString()); } return result; } @Override protected void onPostExecute(String msg) { // mDisplay.append(msg + "\n"); Log.i(LOG_TAG, msg.toString()); onFinishDataLoading(); } }.execute(); }
From source file:org.botlibre.sdk.activity.MicConfiguration.java
public void recording(View v) { if (recording) { setMicIcon(true, true);//from w w w .j av a2s . c om try { //mediaPlayer myAudioRecorder = new MediaRecorder(); myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); myAudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); myAudioRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB); myAudioRecorder.setOutputFile(outputFile); myAudioRecorder.prepare(); myAudioRecorder.start(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } play.setEnabled(false); txt.setText("Status: Recording..."); recording = false; } else { myAudioRecorder.stop(); myAudioRecorder.release(); play.setEnabled(true); txt.setText("Status: Audio Recorded"); setMicIcon(false, false); recording = true; } }
From source file:it.drwolf.ridire.index.cwb.scripts.VRTFilesBuilder.java
@Asynchronous public void buildFiles(VRTFilesBuilderData vrtFilesBuilderData) { this.entityManager = (EntityManager) Component.getInstance("entityManager"); this.userTx = (UserTransaction) org.jboss.seam.Component .getInstance("org.jboss.seam.transaction.transaction"); try {/* w ww . j a v a2s .com*/ this.userTx.setTransactionTimeout(1000 * 10 * 60); if (!this.userTx.isActive()) { this.userTx.begin(); } this.entityManager.joinTransaction(); List<Integer> validatedJobsId = this.entityManager .createQuery("select j.id from Job j where j.validationStatus=:validated") .setParameter("validated", Job.VALIDATED_OK).getResultList(); this.entityManager.flush(); this.entityManager.clear(); this.userTx.commit(); int countJob = 1; for (Integer jobId : validatedJobsId) { System.out.println("Creating VRT files; job " + countJob + " of " + validatedJobsId.size()); ++countJob; this.processResourcesOfJob(jobId, vrtFilesBuilderData); } } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HeuristicMixedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HeuristicRollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { if (this.userTx != null && this.userTx.isActive()) { this.userTx.rollback(); } } catch (IllegalStateException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SystemException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }
From source file:com.tct.mail.ui.OnePaneController.java
@Override public void showConversationList(ConversationListContext listContext) { super.showConversationList(listContext); // TS: tao.gan 2015-09-21 EMAIL FEATURE-559893 ADD_S //we change from ConversationViewFramgent to ConversationListFragment, should let the toolbar show animateShow(null);/*from ww w . j a v a2 s. c om*/ // TS: tao.gan 2015-09-21 EMAIL FEATURE-559893 ADD_E enableCabMode(); mConversationListVisible = true; if (ConversationListContext.isSearchResult(listContext)) { mViewMode.enterSearchResultsListMode(); } else { mViewMode.enterConversationListMode(); } final int transition = mConversationListNeverShown ? FragmentTransaction.TRANSIT_FRAGMENT_FADE : FragmentTransaction.TRANSIT_FRAGMENT_OPEN; final Fragment conversationListFragment = ConversationListFragment.newInstance(listContext); if (!inInbox(mAccount, listContext)) { // Maintain fragment transaction history so we can get back to the // fragment used to launch this list. // AM: Kexue.Geng 2015-03-23 EMAIL BUGFIX_953177 MOD_S // mLastConversationListTransactionId = replaceFragment(conversationListFragment, // transition, TAG_CONVERSATION_LIST, R.id.content_pane); try { mLastConversationListTransactionId = replaceFragment(conversationListFragment, transition, TAG_CONVERSATION_LIST, R.id.content_pane); } catch (IllegalStateException e) { e.printStackTrace(); mLastConversationListTransactionId = INVALID_ID; } // AM: Kexue.Geng 2015-03-23 EMAIL BUGFIX_953177 MOD_E } else { // If going to the inbox, clear the folder list transaction history. mInbox = listContext.folder; // TS: zhaotianyong 2015-05-21 EMAIL BUGFIX_1008675 MOD_S try { replaceFragment(conversationListFragment, transition, TAG_CONVERSATION_LIST, R.id.content_pane); } catch (IllegalStateException e) { LogUtils.e(LogUtils.TAG, e, "showConversationList error"); //TS: zheng.zou 2015-07-01 EMAIL BUGFIX-1033368 MOD } // TS: zhaotianyong 2015-05-21 EMAIL BUGFIX_1008675 MOD_E // If we ever to to the inbox, we want to unset the transation id for any other // non-inbox folder. mLastConversationListTransactionId = INVALID_ID; } //TS: zheng.zou 2015-07-01 EMAIL BUGFIX-1033368 MOD_S if (!mActivity.isDestroyed()) { try { mActivity.getFragmentManager().executePendingTransactions(); } catch (IllegalStateException e) { LogUtils.e(LogUtils.TAG, e, "showConversationList error"); } } else { LogUtils.w(LOG_TAG, "showConversationList activity is destroyed"); } //TS: zheng.zou 2015-07-01 EMAIL BUGFIX-1033368 MOD_E onConversationVisibilityChanged(false); onConversationListVisibilityChanged(true); mConversationListNeverShown = false; }
From source file:info.ajaxplorer.client.http.RestRequest.java
public void discardResponse(HttpResponse response) { try {//from w w w . j a v a2s . com BufferedReader in = null; in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); } catch (IllegalStateException e) { // Silent, was already consumed } catch (Exception e) { e.printStackTrace(); } }
From source file:it.drwolf.ridire.index.cwb.scripts.VRTFilesBuilder.java
@Asynchronous public void buildFilesFromJobNames(VRTFilesBuilderData vrtFilesBuilderData) { String[] jobNames = StringUtils.split(vrtFilesBuilderData.getJobsList(), "\n"); this.entityManager = (EntityManager) Component.getInstance("entityManager"); this.userTx = (UserTransaction) org.jboss.seam.Component .getInstance("org.jboss.seam.transaction.transaction"); try {/*w w w . j a v a 2 s . c o m*/ this.userTx.setTransactionTimeout(1000 * 10 * 60); List<Integer> jobIds = new ArrayList<Integer>(); int countJob = 1; for (String jobName : jobNames) { if (!this.userTx.isActive()) { this.userTx.begin(); } this.entityManager.joinTransaction(); jobName = jobName.replaceAll("completed-", ""); jobIds = this.entityManager.createQuery("select j.id from Job j where j.name=:name ") .setParameter("name", jobName.trim()).getResultList(); this.entityManager.flush(); this.entityManager.clear(); this.userTx.commit(); if (jobIds.size() == 1) { System.out.println("Creating VRT files; job " + countJob + " of " + jobNames.length); ++countJob; this.processResourcesOfJob(jobIds.get(0), vrtFilesBuilderData); } } } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HeuristicMixedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HeuristicRollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { if (this.userTx != null && this.userTx.isActive()) { this.userTx.rollback(); } } catch (IllegalStateException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SystemException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }