List of usage examples for android.util Log INFO
int INFO
To view the source code for android.util Log INFO.
Click Source Link
From source file:com.google.android.gcm.demo.logic.DeviceGroupsHelper.java
/** * Execute the HTTP call to remove registration_ids from a the Device Group. * * <code>/* w ww .ja v a2 s . c o m*/ * Content-Type: application/json * Authorization: key=API_KEY * project_id: SENDER_ID * { * "operation": "add", * "notification_key_name": "appUser-Chris", * "notification_key": "aUniqueKey", * "registration_ids": ["4", "8", "15", "16", "23", "42"] * } * </code> */ public void addMembers(String senderId, String apiKey, String groupName, String groupKey, Bundle members) { try { HttpRequest httpRequest = new HttpRequest(); httpRequest.setHeader(HEADER_CONTENT_TYPE, CONTENT_TYPE_JSON); httpRequest.setHeader(HEADER_AUTHORIZATION, "key=" + apiKey); httpRequest.setHeader(HEADER_PROJECT_ID, senderId); JSONObject requestBody = new JSONObject(); requestBody.put("operation", "add"); requestBody.put("notification_key_name", groupName); requestBody.put("notification_key", groupKey); requestBody.put("registration_ids", new JSONArray(bundleValues2Array(members))); httpRequest.doPost(GCM_GROUPS_ENDPOINT, requestBody.toString()); JSONObject responseBody = new JSONObject(httpRequest.getResponseBody()); if (responseBody.has("error")) { mLogger.log(Log.INFO, "Error while adding new group members." + "\ngroupName: " + groupName + "\ngroupKey: " + groupKey + "\nhttpResponse: " + httpRequest.getResponseBody()); MainActivity.showToast(mContext, R.string.group_toast_add_members_failed, responseBody.getString("error")); } else { // Store the group in the local storage. Sender sender = mSenders.getSender(senderId); DeviceGroup newGroup = sender.groups.get(groupName); for (String name : members.keySet()) { newGroup.tokens.put(name, members.getString(name)); } mSenders.updateSender(sender); mLogger.log(Log.INFO, "Group members added successfully." + "\ngroupName: " + groupName + "\ngroupKey: " + groupKey); MainActivity.showToast(mContext, R.string.group_toast_add_members_succeeded); } } catch (JSONException | IOException e) { mLogger.log(Log.INFO, "Exception while adding new group members." + "\nerror: " + e.getMessage() + "\ngroupName: " + groupName + "\ngroupKey: " + groupKey); MainActivity.showToast(mContext, R.string.group_toast_add_members_failed, e.getMessage()); } }
From source file:com.radicaldynamic.groupinform.services.InformOnlineService.java
private boolean checkin() { // Assume we are registered unless told otherwise boolean registered = true; List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("deviceId", Collect.getInstance().getInformOnlineState().getDeviceId())); params.add(/*from w w w . j a va 2 s . c o m*/ new BasicNameValuePair("deviceKey", Collect.getInstance().getInformOnlineState().getDeviceKey())); params.add(new BasicNameValuePair("fingerprint", Collect.getInstance().getInformOnlineState().getDeviceFingerprint())); try { params.add(new BasicNameValuePair("lastCheckinWith", this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName)); } catch (NameNotFoundException e1) { params.add(new BasicNameValuePair("lastCheckinWith", "unknown")); } String checkinUrl = Collect.getInstance().getInformOnlineState().getServerUrl() + "/checkin"; String postResult = HttpUtils.postUrlData(checkinUrl, params); JSONObject checkin; try { checkin = (JSONObject) new JSONTokener(postResult).nextValue(); String result = checkin.optString(InformOnlineState.RESULT, InformOnlineState.FAILURE); if (result.equals(InformOnlineState.OK)) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "successful checkin"); Collect.getInstance().getInformOnlineState().setExpired(false); // Update device role -- it might have changed Collect.getInstance().getInformOnlineState() .setDeviceRole(checkin.optString("role", AccountDevice.ROLE_UNASSIGNED)); } else if (result.equals(InformOnlineState.EXPIRED)) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "associated order is expired; marking device as expired"); Collect.getInstance().getInformOnlineState().setExpired(true); } else if (result.equals(InformOnlineState.FAILURE)) { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, t + "checkin unsuccessful"); registered = false; } else { // Something bad happened if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "system error while processing postResult"); } } catch (NullPointerException e) { // Communication error if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "no postResult to parse. Communication error with node.js server?"); e.printStackTrace(); } catch (JSONException e) { // Parse error (malformed result) if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "failed to parse postResult " + postResult); e.printStackTrace(); } // Clear the session for subsequent requests and reset stored state if (registered == false) Collect.getInstance().getInformOnlineState().resetDevice(); return registered; }
From source file:org.andstatus.app.util.MyLog.java
/** * Initialize using a double-check idiom *//* w w w.j a va 2s. com*/ private static void checkInit() { if (initialized) { return; } synchronized (lock) { if (initialized) { return; } MyContext myContext = MyContextHolder.get(); if (!myContext.initialized()) { return; } // The class was not initialized yet. String val = "(not set)"; try { SharedPreferences sp = MyPreferences.getDefaultSharedPreferences(); if (sp != null) { val = getMinLogLevel(sp); } setLogToFile(MyPreferences.getBoolean(MyPreferences.KEY_LOG_EVERYTHING_TO_FILE, false)); } catch (Exception e) { Log.e(TAG, "Error in isLoggable", e); } if (Log.INFO >= minLogLevel) { Log.i(TAG, MyPreferences.KEY_MIN_LOG_LEVEL + "='" + val + "'"); } initialized = true; } }
From source file:com.google.android.gcm.demo.ui.MainActivity.java
@Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); setContentView(R.layout.activity_main); mLogger = new Logger(this); mLogsUI = (TextView) findViewById(R.id.logs); mLoggerCallback = new BroadcastReceiver() { @Override/*from w w w. j a v a 2 s .c o m*/ public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case LoggingService.ACTION_CLEAR_LOGS: mLogsUI.setText(""); break; case LoggingService.ACTION_LOG: StringBuilder stringBuilder = new StringBuilder(); String newLog = intent.getStringExtra(LoggingService.EXTRA_LOG_MESSAGE); String oldLogs = Html.toHtml(new SpannableString(mLogsUI.getText())); appendFormattedLogLine(newLog, stringBuilder); stringBuilder.append(oldLogs); mLogsUI.setText(Html.fromHtml(stringBuilder.toString())); List<Fragment> fragments = getSupportFragmentManager().getFragments(); for (Fragment fragment : fragments) { if (fragment instanceof RefreshableFragment && fragment.isVisible()) { ((RefreshableFragment) fragment).refresh(); } } break; } } }; Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerView = (FrameLayout) findViewById(R.id.navigation_drawer); mDrawerMenu = (ListView) findViewById(R.id.navigation_drawer_menu); mDrawerScrim = findViewById(R.id.navigation_drawer_scrim); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); TypedArray colorPrimaryDark = getTheme().obtainStyledAttributes(new int[] { R.attr.colorPrimaryDark }); mDrawerLayout.setStatusBarBackgroundColor(colorPrimaryDark.getColor(0, 0xFF000000)); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); colorPrimaryDark.recycle(); ImageView drawerHeader = new ImageView(this); drawerHeader.setImageResource(R.drawable.drawer_gcm_logo); mDrawerMenu.addHeaderView(drawerHeader); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // Set the drawer width accordingly with the guidelines: window_width - toolbar_height. toolbar.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { if (left == 0 && top == 0 && right == 0 && bottom == 0) { return; } DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); float logicalDensity = metrics.density; int maxWidth = (int) Math.ceil(320 * logicalDensity); DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) mDrawerView.getLayoutParams(); int newWidth = view.getWidth() - view.getHeight(); params.width = (newWidth > maxWidth ? maxWidth : newWidth); mDrawerView.setLayoutParams(params); } }); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { mDrawerView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @TargetApi(Build.VERSION_CODES.KITKAT_WATCH) @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { // Set scrim height to match status bar height. mDrawerScrim.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, insets.getSystemWindowInsetTop())); return insets; } }); } int activeItemIndicator = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) ? android.R.layout.simple_list_item_activated_1 : android.R.layout.simple_list_item_checked; mMainMenu = new MainMenu(this); mDrawerMenu.setOnItemClickListener(this); mDrawerMenu.setAdapter(new ArrayAdapter<>(getSupportActionBar().getThemedContext(), activeItemIndicator, android.R.id.text1, mMainMenu.getEntries())); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerOpened(View drawerView) { // The user learned how to open the drawer. Do not open it for him anymore. getAppPreferences().edit().putBoolean(PREF_OPEN_DRAWER_AT_STARTUP, false).apply(); super.onDrawerOpened(drawerView); } }; boolean activityResumed = (savedState != null); boolean openDrawer = getAppPreferences().getBoolean(PREF_OPEN_DRAWER_AT_STARTUP, true); int lastScreenId = getAppPreferences().getInt(PREF_LAST_SCREEN_ID, 0); selectItem(lastScreenId); if (!activityResumed && openDrawer) { mDrawerLayout.openDrawer(mDrawerView); } mDrawerLayout.setDrawerListener(mDrawerToggle); /* * Here we check if the Activity was created by the user clicking on one of our GCM * notifications: * 1. Check if the action of the intent used to launch the Activity. * 2. Print out any additional data sent with the notification. This is included as extras * on the intent. */ Intent launchIntent = getIntent(); if ("gcm_test_app_notification_click_action".equals(launchIntent.getAction())) { Bundle data = launchIntent.getExtras(); data.isEmpty(); // Force the bundle to unparcel so that toString() works String format = getResources().getString(R.string.notification_intent_received); mLogger.log(Log.INFO, String.format(format, data)); } }
From source file:net.vleu.par.android.rpc.Transceiver.java
/** * This method may block while a network request completes, and must never * be made from the main thread. It requests a new GoogleAuthToken. * //www . j a v a2 s . c o m * @param account * The account to fetch an auth token for * @return A token associated with this account * @throws OperationCanceledException * if the request was canceled for any reason, including the * user canceling a credential request * @throws AuthenticatorException * if the authenticator failed to respond * @throws IOException * if the authenticator experienced an I/O problem creating a * new auth token, usually because of network trouble */ private GoogleAuthToken blockingGetNewAuthToken() throws OperationCanceledException, AuthenticatorException, IOException { final AccountManager am = AccountManager.get(this.context); final String authTokenStr = am.blockingGetAuthToken(this.account, APPENGINE_TOKEN_TYPE, true); if (Log.isLoggable(TAG, Log.INFO)) Log.i(TAG, "Got a new GoogleAuthToken for account: " + this.account.name + ": " + authTokenStr); if (authTokenStr == null) throw new AuthenticatorException("Could not get an auth token"); else return new GoogleAuthToken(authTokenStr); }
From source file:com.cryart.sabbathschool.viewmodel.SSQuarterliesViewModel.java
private void loadLanguages() { ssQuarterliesLoadingVisibility.set(View.VISIBLE); ssQuarterliesListVisibility.set(View.INVISIBLE); ssQuarterliesErrorMessageVisibility.set(View.INVISIBLE); ssQuarterliesEmptyStateVisibility.set(View.INVISIBLE); ssQuarterliesErrorStateVisibility.set(View.INVISIBLE); ssLanguagesRef = ssFirebaseDatabase.child(SSConstants.SS_FIREBASE_LANGUAGES_DATABASE) .addValueEventListener(new ValueEventListener() { @Override/* ww w . ja va 2s . co m*/ public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot != null) { Iterable<DataSnapshot> data = dataSnapshot.getChildren(); try { if (ssQuarterlyLanguages == null) { ssQuarterlyLanguages = new ArrayList<>(); } else { ssQuarterlyLanguages.clear(); } for (DataSnapshot d : data) { SSQuarterlyLanguage _ssQuarterlyLanguage = d .getValue(SSQuarterlyLanguage.class); _ssQuarterlyLanguage.name = getDisplayLanguageByCode(_ssQuarterlyLanguage.code); if (_ssQuarterlyLanguage.code.equalsIgnoreCase(ssDefaultLanguage)) { _ssQuarterlyLanguage.selected = 1; ssQuarterlyLanguage = _ssQuarterlyLanguage; ssQuarterlyLanguages.add(0, _ssQuarterlyLanguage); } else { ssQuarterlyLanguages.add(_ssQuarterlyLanguage); } } if (ssQuarterlyLanguages.size() > 0) { ssQuarterlyLanguage = ssQuarterlyLanguages.get(0); ssQuarterlyLanguage.selected = 1; } if (dataListener != null) dataListener.onQuarterliesLanguagesChanged(ssQuarterlyLanguages); loadQuarterlies(getSelectedLanguage()); } catch (Exception e) { Crashlytics.log(Log.INFO, TAG, e.getMessage()); } } } @Override public void onCancelled(DatabaseError databaseError) { ssQuarterliesErrorMessageVisibility.set(View.VISIBLE); ssQuarterliesListVisibility.set(View.INVISIBLE); ssQuarterliesLoadingVisibility.set(View.INVISIBLE); ssQuarterliesEmptyStateVisibility.set(View.INVISIBLE); ssQuarterliesErrorStateVisibility.set(View.VISIBLE); } }); }
From source file:de.madvertise.android.sdk.MadvertiseMraidView.java
@Override public void loadUrl(String url) { MadvertiseUtil.logMessage(null, Log.INFO, "Loading url now: " + url); super.loadUrl(url); }
From source file:de.madvertise.android.sdk.MadvertiseMraidView.java
@Override public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl) {/*from ww w . jav a 2 s. co m*/ MadvertiseUtil.logMessage(null, Log.INFO, "Loading url now: " + baseUrl + " with data: " + data); super.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl); }
From source file:com.irccloud.android.activity.BaseActivity.java
@Override public void onResume() { super.onResume(); IRCCloudApplication.getInstance().onResume(this); File f = new File(getFilesDir(), LOG_FILENAME); if (f.exists()) { android.util.Log.d("IRCCloud", "Removing stale log file"); f.delete();/*from w w w . j a v a 2 s . co m*/ } new ImageListPruneTask().execute((Void) null); String session = getSharedPreferences("prefs", 0).getString("session_key", ""); if (session.length() > 0) { if (conn.notifier) { Crashlytics.log(Log.INFO, "IRCCloud", "Upgrading notifier websocket"); conn.upgrade(); } } else { Intent i = new Intent(this, LoginActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); finish(); } }
From source file:org.thoughtland.xlocation.Util.java
public static String[] getProLicenseUnchecked() { // Get license file name String storageDir = Environment.getExternalStorageDirectory().getAbsolutePath(); File licenseFile = new File(storageDir + File.separator + LICENSE_FILE_NAME); if (!licenseFile.exists()) licenseFile = new File(storageDir + File.separator + ".xlocation" + File.separator + LICENSE_FILE_NAME); String importedLicense = importProLicense(licenseFile); if (importedLicense == null) return null; // Check license file licenseFile = new File(importedLicense); if (licenseFile.exists()) { // Read license try {// w ww . ja v a 2 s . c o m IniFile iniFile = new IniFile(licenseFile); String name = iniFile.get("name", ""); String email = iniFile.get("email", ""); String signature = iniFile.get("signature", ""); if (name == null || email == null || signature == null) return null; else { // Check expiry if (email.endsWith("@faircode.eu")) { long expiry = Long.parseLong(email.split("\\.")[0]); long time = System.currentTimeMillis() / 1000L; if (time > expiry) { Util.log(null, Log.WARN, "Licensing: expired"); return null; } } // Valid return new String[] { name, email, signature }; } } catch (FileNotFoundException ex) { return null; } catch (Throwable ex) { bug(null, ex); return null; } } else Util.log(null, Log.INFO, "Licensing: no license file"); return null; }