List of usage examples for android.util Log w
public static int w(String tag, Throwable tr)
From source file:org.umit.icm.mobile.connectivity.ServiceHTTPS.java
/** * Returns an HTTPS Response String./* w w w . j a v a 2 s . com*/ * * @return String * @see HttpClient */ @Override public String connect() { HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(getServiceURL()); try { HttpResponse httpResponse = httpClient.execute(httpGet); StatusLine statusLine = httpResponse.getStatusLine(); if (statusLine.getStatusCode() != 200) { return "blocked"; } HttpEntity httpEntity = httpResponse.getEntity(); InputStream inputStream = httpEntity.getContent(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); int bytes = 0; byte[] buffer = new byte[1024]; while ((bytes = inputStream.read(buffer)) != -1) { byteArrayOutputStream.write(buffer, 0, bytes); } if (new String(byteArrayOutputStream.toByteArray()) != null) return "normal"; else return "blocked"; } catch (IOException e) { Log.w("####", e.getLocalizedMessage()); return "blocked"; } }
From source file:com.tingtingapps.securesms.mms.IncomingLegacyMmsConnection.java
@Override public @Nullable RetrieveConf retrieve(@NonNull String contentLocation, byte[] transactionId) throws MmsRadioException, ApnUnavailableException, IOException { MmsRadio radio = MmsRadio.getInstance(context); Apn contentApn = new Apn(contentLocation, apn.getProxy(), Integer.toString(apn.getPort()), apn.getUsername(), apn.getPassword()); if (isCdmaDevice()) { Log.w(TAG, "Connecting directly..."); try {/* w w w. j a va 2s . co m*/ return retrieve(contentApn, transactionId, false, false); } catch (IOException | ApnUnavailableException e) { Log.w(TAG, e); } } Log.w(TAG, "Changing radio to MMS mode.."); radio.connect(); try { Log.w(TAG, "Downloading in MMS mode with proxy..."); try { return retrieve(contentApn, transactionId, true, true); } catch (IOException | ApnUnavailableException e) { Log.w(TAG, e); } Log.w(TAG, "Downloading in MMS mode without proxy..."); return retrieve(contentApn, transactionId, true, false); } finally { radio.disconnect(); } }
From source file:org.montanafoodhub.base.get.InitHub.java
private void parseCSV(InputStream inputStream) throws IOException { InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); TextUtils.SimpleStringSplitter simpleStringSplitter = new TextUtils.SimpleStringSplitter(','); String receiveString = ""; boolean firstTime = true; while ((receiveString = bufferedReader.readLine()) != null) { if (firstTime) { // remove header firstTime = false;/*from w w w .j av a 2 s . c o m*/ } else { simpleStringSplitter.setString(receiveString); Iterator<String> iterator = simpleStringSplitter.iterator(); // Hub Name Data Version Grower Hub Data URL // Producer Hub Data Url Order Hub Data Url // Item Hub Data Url Buyer Hub Data Url // Hub Email To Hub Email Subject Buyer Delay // Item Delay Order Delay Producer Delay Data Version Notes Log.w(HubInit.logTag, "+++++ Start init +++++"); if (iterator.hasNext()) { String hubName = iterator.next(); if (!hubName.equals("")) { HubInit.setHubName(hubName); } Log.w(HubInit.logTag, "hubName = " + HubInit.getHubName()); } if (iterator.hasNext()) { String dataVersion = iterator.next(); if (!dataVersion.equals("")) { HubInit.setDataVersion(dataVersion); } Log.w(HubInit.logTag, "dataVersion = " + HubInit.getDataVersion()); } if (iterator.hasNext()) { String growerHubDataUrl = iterator.next(); if (!growerHubDataUrl.equals("")) { HubInit.setGrowerHubDataUrl(growerHubDataUrl); } Log.w(HubInit.logTag, "growerHubDataUrl = " + HubInit.getGrowerHubDataUrl()); } if (iterator.hasNext()) { String producerHubDataUrl = iterator.next(); if (!producerHubDataUrl.equals("")) { HubInit.setProducerHubDataUrl(producerHubDataUrl); } Log.w(HubInit.logTag, "producerHubDataUrl = " + HubInit.getProducerHubDataUrl()); } if (iterator.hasNext()) { String orderHubDataUrl = iterator.next(); if (!orderHubDataUrl.equals("")) { HubInit.setOrderHubDataUrl(orderHubDataUrl); } Log.w(HubInit.logTag, "orderHubDataUrl = " + HubInit.getOrderHubDataUrl()); } if (iterator.hasNext()) { String itemHubDataUrl = iterator.next(); if (!itemHubDataUrl.equals("")) { HubInit.setItemHubDataUrl(itemHubDataUrl); } Log.w(HubInit.logTag, "itemHubDataUrl = " + HubInit.getInitHubDataUrl()); } if (iterator.hasNext()) { String buyerHubDataUrl = iterator.next(); if (!buyerHubDataUrl.equals("")) { HubInit.setBuyerHubDataUrl(buyerHubDataUrl); } Log.w(HubInit.logTag, "buyerHubDataUrl = " + HubInit.getBuyerHubDataUrl()); } if (iterator.hasNext()) { String certificationHubDataUrl = iterator.next(); if (!certificationHubDataUrl.equals("")) { HubInit.setCertificationHubDataUrl(certificationHubDataUrl); } Log.w(HubInit.logTag, "certificationHubDataUrl = " + HubInit.getCertificationHubDataUrl()); } if (iterator.hasNext()) { String adHubDataUrl = iterator.next(); if (!adHubDataUrl.equals("")) { HubInit.setAdHubDataUrl(adHubDataUrl); } Log.w(HubInit.logTag, "adHubDataUrl = " + HubInit.getAdHubDataUrl()); } if (iterator.hasNext()) { String hubEmailTo = iterator.next(); if (!hubEmailTo.equals("")) { HubInit.setHubEmailTo(hubEmailTo); } Log.w(HubInit.logTag, "hubEmailTo = " + HubInit.getHubEmailTo()); } if (iterator.hasNext()) { String hubEmailSubject = iterator.next(); if (!hubEmailSubject.equals("")) { HubInit.setHubEmailSubject(hubEmailSubject); } Log.w(HubInit.logTag, "hubEmailSubject = " + HubInit.getHubEmailSubject()); } if (iterator.hasNext()) { String hubEventCalUrl = iterator.next(); if (!hubEventCalUrl.equals("")) { HubInit.setHubEventCalUrl(hubEventCalUrl); } Log.w(HubInit.logTag, "hubEventCalUrl = " + HubInit.getHubEventCalUrl()); } if (iterator.hasNext()) { String buyerDelay = iterator.next(); if (!buyerDelay.equals("")) { HubInit.setBuyerDelay(Long.parseLong(buyerDelay.trim())); } Log.w(HubInit.logTag, "buyerDelay = " + HubInit.getBuyerDelay()); } if (iterator.hasNext()) { String itemDelay = iterator.next(); if (!itemDelay.equals("")) { HubInit.setItemDelay(Long.parseLong(itemDelay.trim())); } Log.w(HubInit.logTag, "itemDelay = " + HubInit.getItemDelay()); } if (iterator.hasNext()) { String orderDelay = iterator.next(); if (!orderDelay.equals("")) { HubInit.setOrderDelay(Long.parseLong(orderDelay.trim())); } Log.w(HubInit.logTag, "orderDelay = " + HubInit.getOrderDelay()); } if (iterator.hasNext()) { String producerDelay = iterator.next(); if (!producerDelay.equals("")) { HubInit.setProducerDelay(Long.parseLong(producerDelay.trim())); } Log.w(HubInit.logTag, "producerDelay = " + HubInit.getProducerDelay()); } if (iterator.hasNext()) { String certificateDelay = iterator.next(); if (!certificateDelay.equals("")) { HubInit.setCertificateDelay(Long.parseLong(certificateDelay.trim())); } Log.w(HubInit.logTag, "certificateDelay = " + HubInit.getCertificateDelay()); } if (iterator.hasNext()) { String adDelay = iterator.next(); if (!adDelay.equals("")) { HubInit.setAdDelay(Long.parseLong(adDelay.trim())); } Log.w(HubInit.logTag, "adDelay = " + HubInit.getAdDelay()); } if (iterator.hasNext()) { String adPlayRate = iterator.next(); if (!adPlayRate.equals("")) { HubInit.setAdPlayRate(Long.parseLong(adPlayRate.trim())); } Log.w(HubInit.logTag, "adPlayRate = " + HubInit.getAdDelay()); } if (iterator.hasNext()) { String dataVersionNotes = iterator.next(); if (!dataVersionNotes.equals("")) { HubInit.setDataVersionNotes(dataVersionNotes); } Log.w(HubInit.logTag, "dataVersionNotes = " + HubInit.getDataVersionNotes()); } Log.w(HubInit.logTag, "++++++ End init ++++++"); } } }
From source file:org.smssecure.smssecure.mms.IncomingLegacyMmsConnection.java
@Override public @Nullable RetrieveConf retrieve(@NonNull String contentLocation, byte[] transactionId, int subscriptionId) throws MmsRadioException, ApnUnavailableException, IOException { MmsRadio radio = MmsRadio.getInstance(context); Apn contentApn = new Apn(contentLocation, apn.getProxy(), Integer.toString(apn.getPort()), apn.getUsername(), apn.getPassword()); if (isDirectConnect()) { Log.w(TAG, "Connecting directly..."); try {/*from www.jav a2 s.c o m*/ return retrieve(contentApn, transactionId, false, false); } catch (IOException | ApnUnavailableException e) { Log.w(TAG, e); } } Log.w(TAG, "Changing radio to MMS mode.."); radio.connect(); try { Log.w(TAG, "Downloading in MMS mode with proxy..."); try { return retrieve(contentApn, transactionId, true, true); } catch (IOException | ApnUnavailableException e) { Log.w(TAG, e); } Log.w(TAG, "Downloading in MMS mode without proxy..."); return retrieve(contentApn, transactionId, true, false); } finally { radio.disconnect(); } }
From source file:de.tu_berlin.snet.probe.FacebookProbe.java
@Override protected void onStart() { super.onStart(); Log.d(TAG, "onStart"); fbThread = new Thread(new Runnable() { @Override/*w ww . j a v a 2s .c om*/ public void run() { if (!isAvailable()) { Log.w(TAG, "Network not available, aborting."); return; } fetchFacebook(); } }); fbThread.start(); }
From source file:com.google.example.ads.customevents.impl.PercentageHouseAds.java
/** * Requests a banner ad. This method is called by AdMob Mediation when it selects your custom * event network and asks for an ad./*from ww w. ja va2s.com*/ */ @Override public void requestBannerAd(final CustomEventBannerListener bannerListener, final Activity activity, String label, String serverParameter, AdSize adSize, MediationAdRequest mediationAdRequest, Object customEventExtra) { this.bannerListener = bannerListener; String publisherId = ""; double percentage = 0; try { JSONObject jsonObject = new JSONObject(serverParameter); publisherId = jsonObject.getString("publisherId"); percentage = jsonObject.getDouble("percentage"); } catch (JSONException exception) { Log.w(LOGTAG, exception.getMessage()); bannerListener.onFailedToReceiveAd(); return; } // For this demo, we'll override the percentage from the server, and use the percentage // specified in the app. A practical implementation of this custom event puts the percentage // as part of the JSON in the server parameter, so that all inputs are not hardcoded into the // app. try { if (customEventExtra != null) { percentage = (Double) customEventExtra; } else { Log.w(LOGTAG, String.format("Couldn't find percentage in extras with key: %s", label)); bannerListener.onFailedToReceiveAd(); } } catch (Exception exception) { Log.w(LOGTAG, exception.getMessage()); bannerListener.onFailedToReceiveAd(); return; } // Construct a random number. If the random number is higher than the percentage, don't return // a house ad. double random = Math.random() * 100; Log.d(LOGTAG, String.format("Random value is %s", random)); if (random > percentage) { Utils.logAndToast(activity, LOGTAG, String.format("%s > %s, skipping house ad", random, percentage)); bannerListener.onFailedToReceiveAd(); return; } else { Utils.logAndToast(activity, LOGTAG, String.format("%s < %s, requesting house ad", random, percentage)); adView = new AdView(activity, AdSize.BANNER, publisherId); adView.setAdListener(this); adView.loadAd(new AdRequest()); } }
From source file:com.google.wireless.speed.speedometer.util.MeasurementJsonConvertor.java
@SuppressWarnings("unchecked") public static MeasurementTask makeMeasurementTaskFromJson(JSONObject json, Context context) throws IllegalArgumentException { try {//from w ww . j a va 2 s. com String type = String.valueOf(json.getString("type")); Class taskClass = MeasurementTask.getTaskClassForMeasurement(type); Method getDescMethod = taskClass.getMethod("getDescClass"); // The getDescClassForMeasurement() is static and takes no arguments Class descClass = (Class) getDescMethod.invoke(null, (Object[]) null); MeasurementDesc measurementDesc = gson.fromJson(json.toString(), descClass); Object[] cstParams = { measurementDesc, context }; Constructor<MeasurementTask> constructor = taskClass.getConstructor(MeasurementDesc.class, Context.class); return constructor.newInstance(cstParams); } catch (JSONException e) { throw new IllegalArgumentException(e); } catch (SecurityException e) { Log.w(SpeedometerApp.TAG, e.getMessage()); throw new IllegalArgumentException(e); } catch (NoSuchMethodException e) { Log.w(SpeedometerApp.TAG, e.getMessage()); throw new IllegalArgumentException(e); } catch (IllegalArgumentException e) { Log.w(SpeedometerApp.TAG, e.getMessage()); throw new IllegalArgumentException(e); } catch (InstantiationException e) { Log.w(SpeedometerApp.TAG, e.getMessage()); throw new IllegalArgumentException(e); } catch (IllegalAccessException e) { Log.w(SpeedometerApp.TAG, e.getMessage()); throw new IllegalArgumentException(e); } catch (InvocationTargetException e) { Log.w(SpeedometerApp.TAG, e.toString()); throw new IllegalArgumentException(e); } }
From source file:com.onet.OnetAuth.java
public void authorize() { if (Settings.getInstance().get("authorizing") == "true") { Log.w(TAG, "Already authorizing"); return;/*from ww w. ja va 2 s. c o m*/ } nick = Settings.getInstance().get("nick"); password = Settings.getInstance().get("password"); if (!nick.contains("~")) registeredNick = true; override = true; Settings.getInstance().set("authorizing", "true"); current_category = null; current_result = null; downloadChat(); }
From source file:org.mythtv.service.frontends.v25.StatusHelperV25.java
public Status process(final Context context, final LocationProfile locationProfile, final String url) { Log.v(TAG, "process : enter"); if (!NetworkHelper.getInstance().isFrontendConnected(context, locationProfile, url)) { Log.w(TAG, "process : Frontend @ '" + url + "' is unreachable"); return null; }/*from w ww . j a v a2 s. c o m*/ mMythServicesTemplate = (MythServicesTemplate) MythAccessFactory.getServiceTemplateApiByVersion(mApiVersion, url); if (null == mMythServicesTemplate) { Log.w(TAG, "process : Master Backend '" + locationProfile.getHostname() + "' is unreachable"); return null; } Status status = null; try { status = downloadStatus(locationProfile, url); } catch (Exception e) { Log.e(TAG, "process : error", e); status = null; } Log.v(TAG, "process : exit"); return status; }
From source file:com.remobile.file.AssetFilesystem.java
private void lazyInitCaches() { synchronized (listCacheLock) { if (listCache == null) { ObjectInputStream ois = null; try { ois = new ObjectInputStream(assetManager.open("cdvasset.manifest")); listCache = (Map<String, String[]>) ois.readObject(); lengthCache = (Map<String, Long>) ois.readObject(); listCacheFromFile = true; } catch (ClassNotFoundException e) { e.printStackTrace();/*from ww w . j a v a2 s. com*/ } catch (IOException e) { // Asset manifest won't exist if the gradle hook isn't set up correctly. } finally { if (ois != null) { try { ois.close(); } catch (IOException e) { } } } if (listCache == null) { Log.w("AssetFilesystem", "Asset manifest not found. Recursive copies and directory listing will be slow."); listCache = new HashMap<String, String[]>(); } } } }