List of usage examples for android.util Log w
public static int w(String tag, Throwable tr)
From source file:net.fizzl.redditengine.impl.PersistentCookieStore.java
/** * Load Cookies from a file/*from w w w . j av a 2s . co m*/ */ private void load() { RedditApi api = DefaultRedditApi.getInstance(); Context ctx = api.getContext(); try { FileInputStream fis = ctx.openFileInput(cookiestore); ObjectInputStream ois = new ObjectInputStream(fis); SerializableCookieStore tempStore = (SerializableCookieStore) ois.readObject(); super.clear(); for (Cookie c : tempStore.getCookies()) { super.addCookie(c); } ois.close(); fis.close(); } catch (FileNotFoundException e) { Log.w(getClass().getName(), e.getMessage()); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.tih.tihir.ConsumerIrManagerBase.java
@Override public UUID learnIRCmd(int timeout) { Log.w(TAG, "learn IR command is not available on this device"); return null; }
From source file:org.ambientdynamix.update.contextplugin.NexusSource.java
@Override public void cancel() { cancel = true;/*from ww w . j ava 2s . c o m*/ try { if (getRequest != null) getRequest.abort(); } catch (Exception e) { Log.w(TAG, "Exception while aborting getRequest: " + e.toString()); } }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.db.ws.UserWSGetAsyncTask.java
public List<UserDO> listUsers(String sCourseId) { InputStream is = null;/*w w w. j a va 2 s . co m*/ String url = Session.getSingleInstance().getWSPath() + "/_ah/api/userendpoint/v1/user/course/"; url += sCourseId; try { Log.d(CLASSNAME, " Querying to backend " + url); HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(url); HttpResponse response = httpclient.execute(httpget); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Log.w(getClass().getSimpleName(), "Error " + statusCode + " for URL " + url); return null; } HttpEntity entity = response.getEntity(); is = entity.getContent(); } catch (Exception e) { Log.e(CLASSNAME, "Error in http connection " + e.toString()); } Reader reader = new InputStreamReader(is); Gson gson = new Gson(); UserDOList r = gson.fromJson(reader, UserDOList.class); return r.users; }
From source file:read.taz.TazDownloader.java
private void downloadFile() throws ClientProtocolException, IOException { if (tazFile.file.exists()) { Log.w(getClass().getSimpleName(), "File " + tazFile + " exists."); return;/* w ww . ja v a 2 s. c om*/ } HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, 30000); HttpConnectionParams.setSoTimeout(httpParams, 15000); DefaultHttpClient client = new DefaultHttpClient(httpParams); Credentials defaultcreds = new UsernamePasswordCredentials(uname, passwd); client.getCredentialsProvider() .setCredentials(new AuthScope(/* FIXME DRY */"dl.taz.de", 80, AuthScope.ANY_REALM), defaultcreds); URI uri = tazFile.getDownloadURI(); Log.d(getClass().getSimpleName(), "Downloading taz from " + uri); HttpGet get = new HttpGet(uri); HttpResponse response = client.execute(get); if (response.getStatusLine().getStatusCode() != 200) { throw new IOException("Download failed with HTTP Error" + response.getStatusLine().getStatusCode()); } String contentType = response.getEntity().getContentType().getValue(); if (contentType.startsWith("text/html")) { Log.d(getClass().getSimpleName(), "Content type: " + contentType + " encountered. Assuming a non exisiting file"); ByteArrayOutputStream htmlOut = new ByteArrayOutputStream(); response.getEntity().writeTo(htmlOut); String resp = new String(htmlOut.toByteArray()); Log.d(getClass().getSimpleName(), "Response: " + resp); throw new FileNotFoundException("No taz found for date " + tazFile.date.getTime()); } else { FileOutputStream tazOut = new FileOutputStream(tazFile.file); try { response.getEntity().writeTo(tazOut); } finally { tazOut.close(); } } // InputStream docStream = response.getEntity().getContent(); // FileOutputStream out = null; // try { // out = tazOut; // byte[] buf = new byte[4096]; // for (int read = docStream.read(buf); read != -1; read = docStream // .read(buf)) { // out.write(buf, 0, read); // } // } finally { // docStream.close(); // if (out != null) { // out.close(); // } // } }
From source file:com.prestomation.android.sospy.monitor.AppEngineClient.java
public HttpResponse makeRequest(String httpMethod, String urlPath, List<NameValuePair> params) throws Exception { HttpUriRequest request;//from www .j a va2 s . c o m URI uri = new URI(BASE_URL + urlPath); Log.w(TAG, uri.toString()); if (httpMethod == "POST") { request = new HttpPost(uri); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8"); ((HttpPost) request).setEntity(entity); } else if (httpMethod == "DELETE") { request = new HttpDelete(uri); } else { //This should never happen return null; } HttpResponse res = makeRequestNoRetry(request, params); return res; }
From source file:com.google.android.apps.muzei.SourceSubscriberService.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null || intent.getAction() == null) { return;//from w w w . j a v a 2s.co m } String action = intent.getAction(); if (!ACTION_PUBLISH_STATE.equals(action)) { return; } // Handle API call from source String token = intent.getStringExtra(EXTRA_TOKEN); ComponentName selectedSource = SourceManager.getSelectedSource(this); if (selectedSource == null || !TextUtils.equals(token, selectedSource.flattenToShortString())) { Log.w(TAG, "Dropping update from non-selected source, token=" + token + " does not match token for " + selectedSource); return; } SourceState state = null; if (intent.hasExtra(EXTRA_STATE)) { Bundle bundle = intent.getBundleExtra(EXTRA_STATE); if (bundle != null) { state = SourceState.fromBundle(bundle); } } if (state == null) { // If there is no state, there is nothing to change return; } ContentValues values = new ContentValues(); values.put(MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME, selectedSource.flattenToShortString()); values.put(MuzeiContract.Sources.COLUMN_NAME_IS_SELECTED, true); values.put(MuzeiContract.Sources.COLUMN_NAME_DESCRIPTION, state.getDescription()); values.put(MuzeiContract.Sources.COLUMN_NAME_WANTS_NETWORK_AVAILABLE, state.getWantsNetworkAvailable()); JSONArray commandsSerialized = new JSONArray(); int numSourceActions = state.getNumUserCommands(); boolean supportsNextArtwork = false; for (int i = 0; i < numSourceActions; i++) { UserCommand command = state.getUserCommandAt(i); if (command.getId() == MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK) { supportsNextArtwork = true; } else { commandsSerialized.put(command.serialize()); } } values.put(MuzeiContract.Sources.COLUMN_NAME_SUPPORTS_NEXT_ARTWORK_COMMAND, supportsNextArtwork); values.put(MuzeiContract.Sources.COLUMN_NAME_COMMANDS, commandsSerialized.toString()); ContentResolver contentResolver = getContentResolver(); Cursor existingSource = contentResolver.query(MuzeiContract.Sources.CONTENT_URI, new String[] { BaseColumns._ID }, MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME + "=?", new String[] { selectedSource.flattenToShortString() }, null, null); if (existingSource != null && existingSource.moveToFirst()) { Uri sourceUri = ContentUris.withAppendedId(MuzeiContract.Sources.CONTENT_URI, existingSource.getLong(0)); contentResolver.update(sourceUri, values, null, null); } else { contentResolver.insert(MuzeiContract.Sources.CONTENT_URI, values); } if (existingSource != null) { existingSource.close(); } Artwork artwork = state.getCurrentArtwork(); if (artwork != null) { artwork.setComponentName(selectedSource); contentResolver.insert(MuzeiContract.Artwork.CONTENT_URI, artwork.toContentValues()); // Download the artwork contained from the newly published SourceState startService(TaskQueueService.getDownloadCurrentArtworkIntent(this)); } }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.db.ws.UserIdWSGetAsyncTask.java
public List<String> listUserIds(String sCourseId) { InputStream is = null;/* w w w.ja v a 2 s. c o m*/ String url = Session.getSingleInstance().getWSPath() + "/_ah/api/userendpoint/v1/user/course/"; url += sCourseId; try { Log.d(CLASSNAME, " Querying to backend " + url); HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(url); HttpResponse response = httpclient.execute(httpget); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Log.w(getClass().getSimpleName(), "Error " + statusCode + " for URL " + url); return null; } HttpEntity entity = response.getEntity(); is = entity.getContent(); } catch (Exception e) { Log.e(CLASSNAME, "Error in http connection " + e.toString()); } Reader reader = new InputStreamReader(is); Gson gson = new Gson(); UserDOList r = gson.fromJson(reader, UserDOList.class); List<UserDO> usersDO = r.users; List<String> listUserIds = new ArrayList<String>(); // Log.d(CLASSNAME, " Number of users retrieved from backend: " + users.size()); // List<UserDO> lOrderedUsers = orderedUsers(users); // Log.d(CLASSNAME, " Number of users retrieved from ordered list: " + lOrderedUsers.size()); // Log.d(CLASSNAME, toString(lOrderedUsers)); for (UserDO s : usersDO) { Log.d(CLASSNAME, s.toString()); listUserIds.add(s.getUserName()); } return listUserIds; }
From source file:com.app.common.util.IntentUtils.java
public static void startEmailActivity(Context context, String to, String subject, String body) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); if (!TextUtils.isEmpty(to)) { intent.putExtra(Intent.EXTRA_EMAIL, new String[] { to }); }// w ww.j a v a2 s . co m if (!TextUtils.isEmpty(subject)) { intent.putExtra(Intent.EXTRA_SUBJECT, subject); } if (!TextUtils.isEmpty(body)) { intent.putExtra(Intent.EXTRA_TEXT, body); } final PackageManager pm = (PackageManager) context.getPackageManager(); try { if (pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() == 0) { intent.setType("text/plain"); } } catch (Exception e) { Log.w("Exception encountered while looking for email intent receiver.", e); } context.startActivity(intent); }
From source file:cd.education.data.collector.android.external.ExternalDataReaderImpl.java
@Override public void doImport(Map<String, File> externalDataMap) { for (Map.Entry<String, File> stringFileEntry : externalDataMap.entrySet()) { String dataSetName = stringFileEntry.getKey(); File dataSetFile = stringFileEntry.getValue(); if (dataSetFile.exists()) { File dbFile = new File(dataSetFile.getParentFile().getAbsolutePath(), dataSetName + ".db"); if (dbFile.exists()) { // this means the someone updated the csv file, so we need to reload it boolean deleted = dbFile.delete(); if (!deleted) { Log.e(ExternalDataUtil.LOGGER_NAME, dataSetFile.getName() + " has changed but we could not delete the previous DB at " + dbFile.getAbsolutePath()); continue; }// w w w . ja v a2 s. co m } ExternalSQLiteOpenHelper externalSQLiteOpenHelper = new ExternalSQLiteOpenHelper(dbFile); externalSQLiteOpenHelper.importFromCSV(dataSetFile, this, formLoaderTask); if (formLoaderTask.isCancelled()) { Log.w(ExternalDataUtil.LOGGER_NAME, "The import was cancelled, so we need to rollback."); // we need to drop the database file since it might be partially populated. It will be re-created next time. Log.w(ExternalDataUtil.LOGGER_NAME, "Closing database to be deleted " + dbFile); // then close the database SQLiteDatabase db = externalSQLiteOpenHelper.getReadableDatabase(); db.close(); // the physically delete the db. try { FileUtils.forceDelete(dbFile); Log.w(ExternalDataUtil.LOGGER_NAME, "Deleted " + dbFile.getName()); } catch (IOException e) { Log.e(ExternalDataUtil.LOGGER_NAME, e.getMessage(), e); } // then just exit and do not process any other CSVs. return; } else { // rename the dataSetFile into "dataSetFile.csv.imported" in order not to be loaded again File importedFile = new File(dataSetFile.getParentFile(), dataSetFile.getName() + ".imported"); boolean renamed = dataSetFile.renameTo(importedFile); if (!renamed) { Log.e(ExternalDataUtil.LOGGER_NAME, dataSetFile.getName() + " could not be renamed to be archived. It will be re-imported again! :("); } else { Log.e(ExternalDataUtil.LOGGER_NAME, dataSetFile.getName() + " was renamed to " + importedFile.getName()); } } } } }