List of usage examples for android.util Log ERROR
int ERROR
To view the source code for android.util Log ERROR.
Click Source Link
From source file:com.radicaldynamic.groupinform.services.InformOnlineService.java
private void connect(boolean forceOnline) { mConnecting = true;/* w w w . j a v a2 s . c o m*/ // Make sure that the user has not specifically requested that we be offline if (Collect.getInstance().getInformOnlineState().isOfflineModeEnabled() && forceOnline == false) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "offline mode enabled; not auto-connecting"); /* * This is not a complete initialization (in the sense that we attempted connection) but we need * to pretend that it is so that the UI can move forward to whatever state is most suitable. */ mInitialized = true; mConnecting = false; return; } if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "pinging " + Collect.getInstance().getInformOnlineState().getServerUrl()); // Try to ping the service to see if it is "up" (and determine whether we are registered) String pingUrl = Collect.getInstance().getInformOnlineState().getServerUrl() + "/ping"; String getResult = HttpUtils.getUrlData(pingUrl); JSONObject ping; try { ping = (JSONObject) new JSONTokener(getResult).nextValue(); String result = ping.optString(InformOnlineState.RESULT, InformOnlineState.ERROR); // Online and registered (checked in) if (result.equals(InformOnlineState.OK)) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "ping successful (we are connected and checked in)"); mServicePingSuccessful = mSignedIn = true; } else if (result.equals(InformOnlineState.FAILURE)) { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, t + "ping successful but not signed in (will attempt checkin)"); mServicePingSuccessful = true; if (Collect.getInstance().getInformOnlineState().hasRegistration() && checkin()) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "checkin successful (we are connected)"); // Fetch regardless of the fact that we're not yet marked as being signed in AccountDeviceList.fetchDeviceList(true); AccountFolderList.fetchFolderList(true); mSignedIn = true; } else { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, t + "checkin failed (registration invalid)"); mSignedIn = false; } } else { // Assume offline if (Collect.Log.WARN) Log.w(Collect.LOGTAG, t + "ping failed (we are offline)"); mSignedIn = false; } } catch (NullPointerException e) { // This usually indicates a communication error and will send us into an offline state if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "ping error while communicating with service (we are offline)"); e.printStackTrace(); mServicePingSuccessful = mSignedIn = false; } catch (JSONException e) { // Parse errors (malformed result) send us into an offline state if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "ping error while parsing getResult " + getResult + " (we are offline)"); e.printStackTrace(); mServicePingSuccessful = mSignedIn = false; } finally { // Load regardless of whether we are signed in AccountDeviceList.loadDeviceList(); AccountFolderList.loadFolderList(); // Unblock mInitialized = true; mConnecting = false; } }
From source file:org.inframiner.firebase.starter.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.crash_menu: FirebaseCrash.logcat(Log.ERROR, TAG, "crash caused"); causeCrash();/* w w w . ja va2 s . c o m*/ return true; case R.id.invite_menu: sendInvitation(); return true; case R.id.fresh_config_menu: fetchConfig(); return true; case R.id.sign_out_menu: mFirebaseAuth.signOut(); Auth.GoogleSignInApi.signOut(mGoogleApiClient); mUsername = ANONYMOUS; startActivity(new Intent(this, SignInActivity.class)); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.googlecode.eyesfree.brailleback.SearchNavigationMode.java
/** * Formats some braille content from an {@link AccessibilityNodeInfoCompat}. * Marks the description with a cursor right after the last character * matching the search query. Returns content with keep pan strategy * by default, or reset pan strategy if there is no matched node stored yet. *//* w ww . jav a 2 s . c o m*/ private DisplayManager.Content formatNodeToBraille(AccessibilityNodeInfoCompat node) { if (node == null) { return null; } DisplayManager.Content content = mNodeBrailler.brailleNode(node); if (content == null) { return null; } Spanned spanned = content.getSpanned(); if (spanned == null) { LogUtils.log(this, Log.ERROR, "No text for node"); return null; } // Find index of match and the index corresponding to the // end of the matched text so we know where to place the cursor. String lowerCase = spanned.toString().toLowerCase(); String matchText = mQueryText.toString().toLowerCase(); AccessibilityNodeInfoCompat spanNode = (AccessibilityNodeInfoCompat) DisplaySpans.getEqualSpan(spanned, node); int cursorIndex = -1; if (spanNode != null) { int nodeIndex = spanned.getSpanStart(spanNode); if (nodeIndex >= 0 && nodeIndex < lowerCase.length()) { int matchIndex = lowerCase.indexOf(matchText, nodeIndex); if (matchIndex >= 0 && matchIndex <= lowerCase.length()) { cursorIndex = matchIndex + matchText.length(); } } } // Add prefix to what's displayed to mark this as a search result. String prefix = mAccessibilityService.getString(R.string.search_result_prefix); int lengthDiff = prefix.length(); SpannableStringBuilder sb = (SpannableStringBuilder) spanned; sb.insert(0, prefix); // If match in this node, add cursor at end of match. if (cursorIndex != -1) { DisplaySpans.addSelection(sb, cursorIndex + lengthDiff, cursorIndex + lengthDiff); } // No matched node stored, means we have just activated search mode, // so we want to reset the panning frame so we can see the search // prefix. int panStrategy = AccessibilityNodeInfoRef.isNull(mMatchedNode) ? DisplayManager.Content.PAN_RESET : DisplayManager.Content.PAN_KEEP; return content.setPanStrategy(panStrategy); }
From source file:com.radicaldynamic.groupinform.services.DatabaseService.java
synchronized private void connectToLocalServer() throws DbUnavailableException { final String tt = t + "connectToLocalServer(): "; if (mLocalHost == null || mLocalPort == 0) { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, tt + "local host information not available; aborting connection"); mConnectedToLocal = false;/*from w w w . java2s . co m*/ return; } if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, tt + "establishing connection to " + mLocalHost + ":" + mLocalPort); try { /* * Socket timeout of 5 minutes is important, otherwise long-running replications * will fail. It is possible that we will need to extend this in the future if * it turns out to be insufficient. */ mLocalHttpClient = new StdHttpClient.Builder().host(mLocalHost).port(mLocalPort) .socketTimeout(TIME_FIVE_MINUTES * 1000).build(); mLocalDbInstance = new StdCouchDbInstance(mLocalHttpClient); mLocalDbInstance.getAllDatabases(); if (mConnectedToLocal == false) mConnectedToLocal = true; if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, tt + "connection to " + mLocalHost + " successful"); } catch (Exception e) { if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, tt + e.toString()); e.printStackTrace(); mConnectedToLocal = false; throw new DbUnavailableException(); } }
From source file:com.radicaldynamic.groupinform.activities.AccountFolderList.java
public static ArrayList<AccountFolder> loadFolderList() { if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, t + "loading folder cache"); ArrayList<AccountFolder> folders = new ArrayList<AccountFolder>(); if (!new File(Collect.getInstance().getCacheDir(), FileUtilsExtended.FOLDER_CACHE_FILE).exists()) { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, t + "folder cache file cannot be read: aborting loadFolderList()"); return folders; }//from ww w.ja va 2s . co m try { FileInputStream fis = new FileInputStream( new File(Collect.getInstance().getCacheDir(), FileUtilsExtended.FOLDER_CACHE_FILE)); InputStreamReader reader = new InputStreamReader(fis); BufferedReader buffer = new BufferedReader(reader, 8192); StringBuilder sb = new StringBuilder(); String cur; while ((cur = buffer.readLine()) != null) { sb.append(cur + "\n"); } buffer.close(); reader.close(); fis.close(); try { JSONArray jsonFolders = (JSONArray) new JSONTokener(sb.toString()).nextValue(); for (int i = 0; i < jsonFolders.length(); i++) { JSONObject jsonFolder = jsonFolders.getJSONObject(i); AccountFolder folder = new AccountFolder(jsonFolder.getString("id"), jsonFolder.getString("rev"), jsonFolder.getString("owner"), jsonFolder.getString("name"), jsonFolder.getString("description"), jsonFolder.getString("visibility"), jsonFolder.getBoolean("replication")); folders.add(folder); // Also update the account folder hash since this will be needed by BrowserActivity, among other things Collect.getInstance().getInformOnlineState().getAccountFolders().put(folder.getId(), folder); } } catch (JSONException e) { // Parse error (malformed result) if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "failed to parse JSON " + sb.toString()); e.printStackTrace(); } } catch (Exception e) { if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "unable to read folder cache: " + e.toString()); e.printStackTrace(); } return folders; }
From source file:com.google.android.marvin.mytalkback.TalkBackService.java
/** * Suspends TalkBack and Explore by Touch. */// w w w . j ava 2 s . c o m private void suspendTalkBack() { if (!isServiceActive()) { LogUtils.log(this, Log.ERROR, "Attempted to suspend TalkBack while already suspended."); return; } mFeedbackController.playAuditory(R.id.sounds_paused_feedback); if (SUPPORTS_TOUCH_PREF) { requestTouchExploration(false); } if (mCursorController != null) { mCursorController.clearCursor(); } final IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_RESUME_FEEDBACK); filter.addAction(Intent.ACTION_SCREEN_ON); registerReceiver(mSuspendedReceiver, filter, PERMISSION_TALKBACK, null); // Suspending infrastructure sets sIsTalkBackSuspended to true. suspendInfrastructure(); final Intent resumeIntent = new Intent(ACTION_RESUME_FEEDBACK); final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, resumeIntent, 0); final Notification notification = new NotificationCompat.Builder(this) .setContentTitle(getString(R.string.notification_title_talkback_suspended)) .setContentText(getString(R.string.notification_message_talkback_suspended)) .setPriority(NotificationCompat.PRIORITY_MAX).setSmallIcon(R.drawable.ic_stat_info) .setContentIntent(pendingIntent).setOngoing(true).setWhen(0).build(); startForeground(R.id.notification_suspended, notification); }
From source file:com.google.android.marvin.screenspeak.ScreenSpeakService.java
/** * Suspends ScreenSpeak and Explore by Touch. *///from w w w . jav a 2 s. c o m public void suspendScreenSpeak() { if (!isServiceActive()) { if (LogUtils.LOG_LEVEL <= Log.ERROR) { Log.e(LOGTAG, "Attempted to suspend ScreenSpeak while already suspended."); } return; } SharedPreferencesUtils.storeBooleanAsync(mPrefs, getString(R.string.pref_suspended), true); mFeedbackController.playAuditory(R.raw.paused_feedback); if (mSupportsTouchScreen) { requestTouchExploration(false); } if (mCursorController != null) { try { mCursorController.clearCursor(); } catch (SecurityException e) { if (LogUtils.LOG_LEVEL >= Log.ERROR) { Log.e(LOGTAG, "Unable to clear cursor"); } } } final IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_RESUME_FEEDBACK); filter.addAction(Intent.ACTION_SCREEN_ON); registerReceiver(mSuspendedReceiver, filter, PERMISSION_SCREENSPEAK, null); // Suspending infrastructure sets sIsScreenSpeakSuspended to true. suspendInfrastructure(); final Intent resumeIntent = new Intent(ACTION_RESUME_FEEDBACK); final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, resumeIntent, 0); final Notification notification = new NotificationCompat.Builder(this) .setContentTitle(getString(R.string.notification_title_screenspeak_suspended)) .setContentText(getString(R.string.notification_message_screenspeak_suspended)) .setPriority(NotificationCompat.PRIORITY_MAX).setSmallIcon(R.drawable.ic_stat_info) .setContentIntent(pendingIntent).setOngoing(true).setWhen(0).build(); startForeground(R.id.notification_suspended, notification); mSpeechController.speak(getString(R.string.screenspeak_suspended), SpeechController.QUEUE_MODE_UNINTERRUPTIBLE, 0, null); }
From source file:android.app.FragmentManager.java
private void throwException(RuntimeException ex) { Log.e(TAG, ex.getMessage());//from w w w .j a v a2s.c om LogWriter logw = new LogWriter(Log.ERROR, TAG); PrintWriter pw = new PrintWriter(logw); if (mActivity != null) { Log.e(TAG, "Activity state:"); try { mActivity.dump(" ", null, pw, new String[] {}); } catch (Exception e) { Log.e(TAG, "Failed dumping state", e); } } else { Log.e(TAG, "Fragment manager state:"); try { dump(" ", null, pw, new String[] {}); } catch (Exception e) { Log.e(TAG, "Failed dumping state", e); } } throw ex; }
From source file:com.radicaldynamic.groupinform.services.DatabaseService.java
synchronized private void connectToRemoteServer() throws DbUnavailableException { final String tt = t + "connectToRemoteServer(): "; String host = getString(R.string.tf_default_ionline_server); int port = 6984; if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, tt + "establishing connection to " + host + ":" + port); try {/*from w w w .j ava 2s . c o m*/ mRemoteHttpClient = new StdHttpClient.Builder().enableSSL(true).host(host).port(port) .socketTimeout(30 * 1000).username(Collect.getInstance().getInformOnlineState().getDeviceId()) .password(Collect.getInstance().getInformOnlineState().getDeviceKey()).build(); mRemoteDbInstance = new StdCouchDbInstance(mRemoteHttpClient); mRemoteDbInstance.getAllDatabases(); if (mConnectedToRemote == false) mConnectedToRemote = true; if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, tt + "connection to " + host + " successful"); } catch (Exception e) { if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, tt + "while connecting to server " + port + ": " + e.toString()); e.printStackTrace(); mConnectedToRemote = false; throw new DbUnavailableException(); } }
From source file:android.app.FragmentManager.java
private void throwException(RuntimeException ex) { Log.e(TAG, ex.getMessage());// ww w .j a v a 2s . co m LogWriter logw = new LogWriter(Log.ERROR, TAG); PrintWriter pw = new FastPrintWriter(logw, false, 1024); if (mActivity != null) { Log.e(TAG, "Activity state:"); try { mActivity.dump(" ", null, pw, new String[] {}); } catch (Exception e) { pw.flush(); Log.e(TAG, "Failed dumping state", e); } } else { Log.e(TAG, "Fragment manager state:"); try { dump(" ", null, pw, new String[] {}); } catch (Exception e) { pw.flush(); Log.e(TAG, "Failed dumping state", e); } } pw.flush(); throw ex; }