List of usage examples for android.util Log v
public static int v(String tag, String msg)
From source file:com.phonegap.bossbolo.plugin.statusbar.StatusBar.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback id used when calling back into JavaScript. * @return True if the action was valid, false otherwise. *///from ww w . j a v a 2s.c o m @Override public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException { Log.v(TAG, "Executing action: " + action); final Activity activity = this.cordova.getActivity(); final Window window = activity.getWindow(); if ("_ready".equals(action)) { boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0; callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible)); } if ("show".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }); return true; } if ("hide".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }); return true; } if ("backgroundColorByHexString".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { try { setStatusBarBackgroundColor(args.getString(0)); } catch (JSONException ignore) { Log.e(TAG, "Invalid hexString argument, use f.i. '#777777'"); } } }); return true; } return false; }
From source file:com.clearcenter.mobile_demo.mdAuthenticator.java
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle loginOptions) throws NetworkErrorException { Log.v(TAG, "getAuthToken()"); // If the caller requested an authToken type we don't support, then // return an error if (!authTokenType.equals(mdConstants.AUTHTOKEN_TYPE)) { final Bundle result = new Bundle(); result.putString(AccountManager.KEY_ERROR_MESSAGE, "invalid authTokenType"); return result; }/*from ww w. j a v a 2 s .co m*/ // Extract the username and password from the Account Manager, and ask // the server for an appropriate AuthToken. final AccountManager am = AccountManager.get(ctx); final String password = am.getPassword(account); final String hostname = am.getUserData(account, "hostname"); final String username = am.getUserData(account, "username"); if (password != null) { try { mdSSLUtil.DisableSecurity(); final String authToken = mdRest.Login(hostname, username, null, password); if (!TextUtils.isEmpty(authToken)) { final Bundle result = new Bundle(); result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); result.putString(AccountManager.KEY_ACCOUNT_TYPE, mdConstants.ACCOUNT_TYPE); result.putString(AccountManager.KEY_AUTHTOKEN, authToken); return result; } } catch (JSONException e) { Log.e(TAG, "JSONException", e); } catch (GeneralSecurityException e) { Log.e(TAG, "GeneralSecurityException", e); } } Log.v(TAG, "Asking for password again..."); // If we get here, then we couldn't access the user's password - so we // need to re-prompt them for their credentials. We do that by creating // an intent to display our mdAuthenticatorActivity panel. final Intent intent = new Intent(ctx, mdAuthenticatorActivity.class); intent.putExtra(mdAuthenticatorActivity.PARAM_NICKNAME, account.name); intent.putExtra(mdAuthenticatorActivity.PARAM_USERNAME, username); intent.putExtra(mdAuthenticatorActivity.PARAM_HOSTNAME, hostname); intent.putExtra(mdAuthenticatorActivity.PARAM_AUTHTOKEN_TYPE, authTokenType); intent.putExtra(mdAuthenticatorActivity.PARAM_CONFIRM_CREDENTIALS, true); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); final Bundle bundle = new Bundle(); bundle.putParcelable(AccountManager.KEY_INTENT, intent); return bundle; }
From source file:com.github.hobbe.android.openkarotz.fragment.ColorFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { Log.v(LOG_TAG, "onActivityCreated, bundle: " + savedInstanceState); super.onActivityCreated(savedInstanceState); if (savedInstanceState == null) { disableFields();//from w ww . j a va2s .co m new GetStatusTask(getActivity()).execute(); } }
From source file:ru.ivanovpv.gorets.psm.mms.transaction.HttpUtils.java
/** * A helper method to send or retrieve data through HTTP protocol. * * @param token The token to identify the sending progress. * @param url The URL used in a GET request. Null when the method is * HTTP_POST_METHOD./* www.ja va2 s .co m*/ * @param pdu The data to be POST. Null when the method is HTTP_GET_METHOD. * @param method HTTP_POST_METHOD or HTTP_GET_METHOD. * @return A byte array which contains the response data. * If an HTTP error code is returned, an IOException will be thrown. * @throws IOException if any error occurred on network interface or * an HTTP error code(>=400) returned from the server. */ public static byte[] httpConnection(Context context, long token, String url, byte[] pdu, int method, boolean isProxySet, String proxyHost, int proxyPort) throws IOException { if (url == null) { throw new IllegalArgumentException("URL must not be null."); } if (DEBUG) { Log.v(TAG, "httpConnection: params list"); Log.v(TAG, "\ttoken\t\t= " + token); Log.v(TAG, "\turl\t\t= " + url); Log.v(TAG, "\tmethod\t\t= " + ((method == HTTP_POST_METHOD) ? "POST" : ((method == HTTP_GET_METHOD) ? "GET" : "UNKNOWN"))); Log.v(TAG, "\tisProxySet\t= " + isProxySet); Log.v(TAG, "\tproxyHost\t= " + proxyHost); Log.v(TAG, "\tproxyPort\t= " + proxyPort); // TODO Print out binary data more readable. //Log.v(TAG, "\tpdu\t\t= " + Arrays.toString(pdu)); } AndroidHttpClient client = null; try { // Make sure to use a proxy which supports CONNECT. URI hostUrl = new URI(url); HttpHost target = new HttpHost(hostUrl.getHost(), hostUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME); client = createHttpClient(context); HttpRequest req = null; switch (method) { case HTTP_POST_METHOD: ProgressCallbackEntity entity = new ProgressCallbackEntity(context, token, pdu); // Set request content type. entity.setContentType("application/vnd.wap.mms-message"); HttpPost post = new HttpPost(url); post.setEntity(entity); req = post; break; case HTTP_GET_METHOD: req = new HttpGet(url); break; default: Log.e(TAG, "Unknown HTTP method: " + method + ". Must be one of POST[" + HTTP_POST_METHOD + "] or GET[" + HTTP_GET_METHOD + "]."); return null; } // Set route parameters for the request. HttpParams params = client.getParams(); if (isProxySet) { ConnRouteParams.setDefaultProxy(params, new HttpHost(proxyHost, proxyPort)); } req.setParams(params); // Set necessary HTTP headers for MMS transmission. req.addHeader(HDR_KEY_ACCEPT, HDR_VALUE_ACCEPT); { String xWapProfileTagName = MmsConfig.getUaProfTagName(); String xWapProfileUrl = MmsConfig.getUaProfUrl(); if (xWapProfileUrl != null) { if (DEBUG) { Log.d(TAG, "[HttpUtils] httpConn: xWapProfUrl=" + xWapProfileUrl); } req.addHeader(xWapProfileTagName, xWapProfileUrl); } } // Extra http parameters. Split by '|' to get a list of value pairs. // Separate each pair by the first occurrence of ':' to obtain a name and // value. Replace the occurrence of the string returned by // MmsConfig.getHttpParamsLine1Key() with the users telephone number inside // the value. String extraHttpParams = MmsConfig.getHttpParams(); if (extraHttpParams != null) { String line1Number = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)) .getLine1Number(); String line1Key = MmsConfig.getHttpParamsLine1Key(); String paramList[] = extraHttpParams.split("\\|"); for (String paramPair : paramList) { String splitPair[] = paramPair.split(":", 2); if (splitPair.length == 2) { String name = splitPair[0].trim(); String value = splitPair[1].trim(); if (line1Key != null) { value = value.replace(line1Key, line1Number); } if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(value)) { req.addHeader(name, value); } } } } req.addHeader(HDR_KEY_ACCEPT_LANGUAGE, HDR_VALUE_ACCEPT_LANGUAGE); HttpResponse response = client.execute(target, req); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) { // HTTP 200 is success. throw new IOException("HTTP error: " + status.getReasonPhrase()); } HttpEntity entity = response.getEntity(); byte[] body = null; if (entity != null) { try { if (entity.getContentLength() > 0) { body = new byte[(int) entity.getContentLength()]; DataInputStream dis = new DataInputStream(entity.getContent()); try { dis.readFully(body); } finally { try { dis.close(); } catch (IOException e) { Log.e(TAG, "Error closing input stream: " + e.getMessage()); } } } if (entity.isChunked()) { Log.v(TAG, "httpConnection: transfer encoding is chunked"); int bytesTobeRead = MmsConfig.getMaxMessageSize(); byte[] tempBody = new byte[bytesTobeRead]; DataInputStream dis = new DataInputStream(entity.getContent()); try { int bytesRead = 0; int offset = 0; boolean readError = false; do { try { bytesRead = dis.read(tempBody, offset, bytesTobeRead); } catch (IOException e) { readError = true; Log.e(TAG, "httpConnection: error reading input stream" + e.getMessage()); break; } if (bytesRead > 0) { bytesTobeRead -= bytesRead; offset += bytesRead; } } while (bytesRead >= 0 && bytesTobeRead > 0); if (bytesRead == -1 && offset > 0 && !readError) { // offset is same as total number of bytes read // bytesRead will be -1 if the data was read till the eof body = new byte[offset]; System.arraycopy(tempBody, 0, body, 0, offset); Log.v(TAG, "httpConnection: Chunked response length [" + Integer.toString(offset) + "]"); } else { Log.e(TAG, "httpConnection: Response entity too large or empty"); } } finally { try { dis.close(); } catch (IOException e) { Log.e(TAG, "Error closing input stream: " + e.getMessage()); } } } } finally { if (entity != null) { entity.consumeContent(); } } } return body; } catch (URISyntaxException e) { handleHttpConnectionException(e, url); } catch (IllegalStateException e) { handleHttpConnectionException(e, url); } catch (IllegalArgumentException e) { handleHttpConnectionException(e, url); } catch (SocketException e) { handleHttpConnectionException(e, url); } catch (Exception e) { handleHttpConnectionException(e, url); } finally { if (client != null) { client.close(); } } return null; }
From source file:nl.frankkie.bronylivewallpaper.CLog.java
public static void v(String tag, String msg) { if (shouldLog && errorLevel <= Log.VERBOSE) { Log.v(tag, msg); } }
From source file:com.github.hobbe.android.openkarotz.fragment.RadioFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.v(LOG_TAG, "onCreateView"); // Fetch the selected page number int index = getArguments().getInt(MainActivity.ARG_PAGE_NUMBER); // List of pages String[] pages = getResources().getStringArray(R.array.pages); // Page title String pageTitle = pages[index]; getActivity().setTitle(pageTitle);//from ww w . jav a 2 s .c o m // Action bar tab navigation actionBar = getActivity().getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); View view = inflater.inflate(R.layout.page_radio, container, false); initializeView(view); Log.v(LOG_TAG, "onCreateView ... done"); return view; }
From source file:com.example.fastgive.CaptureActivity.java
@Override protected void onPause() { super.onPause(); Log.v(TAG, "onPause()"); }
From source file:com.goliathonline.android.kegbot.io.RemoteTapHandler.java
/** {@inheritDoc} */ @Override//from w w w . j a v a 2s . com public ArrayList<ContentProviderOperation> parse(JSONObject parser, ContentResolver resolver) throws JSONException, IOException { final ArrayList<ContentProviderOperation> batch = Lists.newArrayList(); if (parser.has("result")) { JSONObject events = parser.getJSONObject("result"); JSONArray resultArray = events.getJSONArray("taps"); int numKegs = resultArray.length(); JSONObject taps; for (int i = 0; i < numKegs; i++) { taps = resultArray.getJSONObject(i); JSONObject keg = taps.getJSONObject("keg"); JSONObject tap = taps.getJSONObject("tap"); JSONObject beer = taps.getJSONObject("beer_type"); JSONObject image = beer.getJSONObject("image"); final String tapId = sanitizeId(tap.getString("id")); final Uri tapUri = Taps.buildTapUri(tapId); // Check for existing details, only update when changed final ContentValues values = queryTapDetails(tapUri, resolver); final long localUpdated = values.getAsLong(SyncColumns.UPDATED); final long serverUpdated = 500; //entry.getUpdated(); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "found tap " + tapId); Log.v(TAG, "found localUpdated=" + localUpdated + ", server=" + serverUpdated); } // Clear any existing values for this session, treating the // incoming details as authoritative. batch.add(ContentProviderOperation.newDelete(tapUri).build()); final ContentProviderOperation.Builder builder = ContentProviderOperation .newInsert(Taps.CONTENT_URI); builder.withValue(SyncColumns.UPDATED, serverUpdated); builder.withValue(Taps.TAP_ID, tapId); if (tap.has("name")) builder.withValue(Taps.TAP_NAME, tap.getString("name")); if (tap.has("current_keg_id")) builder.withValue(Taps.KEG_ID, tap.getDouble("current_keg_id")); if (keg.has("status")) builder.withValue(Taps.STATUS, keg.getString("status")); if (keg.has("percent_full")) builder.withValue(Taps.PERCENT_FULL, keg.getString("percent_full")); if (keg.has("size_name")) builder.withValue(Taps.SIZE_NAME, keg.getString("size_name")); if (keg.has("volume_ml_remain")) builder.withValue(Taps.VOL_REMAIN, keg.getDouble("volume_ml_remain")); if (keg.has("size_volume_ml")) builder.withValue(Taps.VOL_SIZE, keg.getDouble("size_volume_ml")); if (beer.has("name")) builder.withValue(Taps.BEER_NAME, beer.getString("name")); if (keg.has("description")) builder.withValue(Taps.DESCRIPTION, keg.getString("description")); JSONObject last_temp = tap.getJSONObject("last_temperature"); if (last_temp.has("temperature_c")) builder.withValue(Taps.LAST_TEMP, last_temp.getString("temperature_c")); if (last_temp.has("record_time")) builder.withValue(Taps.LAST_TEMP_TIME, last_temp.getString("record_time")); if (image.has("url")) builder.withValue(Taps.IMAGE_URL, image.getString("url")); // Normal tap details ready, write to provider batch.add(builder.build()); } } return batch; }
From source file:com.midisheetmusicmemo.ChooseSongActivity.java
public void doOpenFile(FileUri file) { byte[] data = file.getData(this); if (data == null || data.length <= 6 || !MidiFile.hasMidiHeader(data)) { ChooseSongActivity.showErrorDialog("Error: Unable to open song: " + file.toString(), this); return;//from www . j a v a2s . c o m } updateRecentFile(file); Intent intent; if (MidiSheetMusicActivity.USE_ORIGINAL_MSM) { intent = new Intent(Intent.ACTION_VIEW, file.getUri(), this, SheetMusicActivity.class); } else { intent = new Intent(this, TommyIntroActivity.class); } Log.v("doOpenFile", "URI: " + file.getUri().toString()); intent.putExtra(SheetMusicActivity.MidiTitleID, file.toString()); intent.putExtra(SheetMusicActivity.MidiDataID, file.getData(this)); intent.putExtra(TommyConfig.FILE_URI_ID, file.toStringFull()); startActivity(intent); }
From source file:com.secretparty.app.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SharedPreferences prefs = this.getPreferences(MODE_PRIVATE); thematicRepo = ((SecretPartyApplication) getApplication()).getThematicRepository(); api = ((SecretPartyApplication) getApplication()).getApiService(); //TODO : check if thematics are in the database. If so, launch a ThematicFragment. Otherwise, download them, save them to the db and launch TheamticFragment int userId = prefs.getInt(getString(R.string.SP_user_id), -1); int partyId = prefs.getInt(getString(R.string.SP_party_id), -1); long partyEnd = prefs.getLong(getString(R.string.SP_date_party_end), -1); Log.v("creation", new Date(partyEnd).toLocaleString() + ""); api.listThematics(new OnReceivedThematics()); if (userId == -1) { DialogFragment df = new UserCreationDialog(); df.setCancelable(false);//from www.j a va2s . co m df.show(getSupportFragmentManager(), "dialog"); } }