Example usage for android.util Log v

List of usage examples for android.util Log v

Introduction

In this page you can find the example usage for android.util Log v.

Prototype

public static int v(String tag, String msg) 

Source Link

Document

Send a #VERBOSE log message.

Usage

From source file:com.digipom.manteresting.android.service.cache.ImageDownloader.java

byte[] download(String uri) {
    final HttpClient httpClient = new DefaultHttpClient();

    HttpGet httpGet = new HttpGet(uri);
    byte[] data = null;

    try {/*from  w w  w  .  ja va2s . c  o m*/
        HttpResponse response = httpClient.execute(httpGet);

        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
            for (String extension : otherExtensionsToTry) {
                final String rewrittenUri = FileUtils.getFileNameWithoutExtension(uri) + '.' + extension;

                if (LoggerConfig.canLog(Log.VERBOSE)) {
                    Log.v(TAG, "Original URI " + uri + " not found. Trying with another extension: "
                            + rewrittenUri);
                }

                // Consume the content so the connection can be re-used.
                response.getEntity().consumeContent();

                httpGet = new HttpGet(rewrittenUri);
                response = httpClient.execute(httpGet);

                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                    break;
                }
            }
        }

        InputStream is = null;

        try {
            final HttpEntity responseEntity = response.getEntity();
            is = responseEntity.getContent();
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final byte[] buffer = new byte[4096];

            int read;
            while ((read = is.read(buffer)) > 0) {
                baos.write(buffer, 0, read);
            }

            data = baos.toByteArray();
        } finally {
            if (is != null) {
                is.close();
                is = null;
            }
        }
    } catch (Throwable t) {
        if (LoggerConfig.canLog(Log.DEBUG)) {
            Log.d(TAG, "Download failed: " + uri, t);
        }
    }

    return data;
}

From source file:at.modalog.cordova.plugin.cache.Cache.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    /*try/*from  w  w w .  j a v  a 2 s .co  m*/
    {
    */
    if (action.equals("clear")) {
        Log.v(LOG_TAG, "Cordova Android Cache.clear() called.");
        this.callbackContext = callbackContext;

        final Cache self = this;
        final Context ctx = this.cordova.getActivity().getApplicationContext();
        cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                try {
                    // clear the cache
                    self.webView.clearCache(true);
                    File dir = ctx.getCacheDir();
                    deleteDir(dir);

                    // send success result to cordova
                    PluginResult result = new PluginResult(PluginResult.Status.OK);
                    result.setKeepCallback(false);
                    self.callbackContext.sendPluginResult(result);
                } catch (Exception e) {
                    String msg = "Error while clearing webview cache.";
                    Log.e(LOG_TAG, msg);

                    // return error answer to cordova
                    PluginResult result = new PluginResult(PluginResult.Status.ERROR, msg);
                    result.setKeepCallback(false);
                    self.callbackContext.sendPluginResult(result);
                }
            }
        });
        return true;
    }
    return false;
    /*
    }
    catch (JSONException e)
    {
    // TODO: signal JSON problem to JS
    //callbackContext.error("Problem with JSON");
    return false;
    }
    */
}

From source file:net.frygo.findmybuddy.GCMIntentService.java

@Override
protected void onMessage(Context arg0, Intent intent) {
    // TODO Auto-generated method stub

    // ---   Called when a cloud message has been received.

    // --- handle here the push notification e.g. Toast Notification
    Log.v("TAG", "GCMIntentService onMessage");
    String message = intent.getStringExtra("ContactNotification");
    if (message != null) {
        generateNotification(arg0, message);

    } //end of if

    else {/*from  w w  w.  j  a v  a 2 s. c  o  m*/
        message = intent.getStringExtra("Location");
        if (message != null) {
            //generateNotification(arg0, message);

            double latitude = 0.0;
            double longitude = 0.0;
            // check if GPS enabled

            GPSTracker gps = new GPSTracker(arg0);
            if (gps.canGetLocation()) {

                latitude = gps.getLatitude();
                longitude = gps.getLongitude();
                gps.stopUsingGPS();

            } //can get location

            final ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

            nameValuePairs.add(
                    new BasicNameValuePair("email_id_2", new SharedPreference(this).retrievedata("email")));
            nameValuePairs.add(new BasicNameValuePair("latitude", String.valueOf(latitude)));
            nameValuePairs.add(new BasicNameValuePair("longitude", String.valueOf(longitude)));
            Getdatawithoutpbar obj = new Getdatawithoutpbar(this, nameValuePairs);
            String ur = URL.url + "updatelatitudelongitude.php";
            obj.execute(ur);

        } //end of if
        else {
            message = intent.getStringExtra("Contactrequestaccepted");
            if (message != null) {
                generateAcceptfriendNotification(arg0, message, "accept");
            } else {
                message = intent.getStringExtra("Contactrequestrejected");
                if (message != null) {
                    generateAcceptfriendNotification(arg0, message, "reject");
                }
            }
        }

    } //end of else

}

From source file:fr.cph.stock.android.activity.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "BaseActivity onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.loading);//from   w  ww .j a  va 2s  .  com
    mLoginStatusView = findViewById(R.id.login_status);
    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);

    if (settings.contains("login") && settings.contains("password")) {
        showProgress(true, null);
        login = settings.getString("login", null);
        password = settings.getString("password", null);
        UrlType urlAuth = UrlType.AUTH;
        String params = "?login=" + login + "&password=" + password;
        MainTask derp = new MainTask(this, urlAuth, params);
        derp.execute((Void) null);
    } else {
        showProgress(false, null);
        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);
        finish();
    }
    EasyTracker.getInstance().setContext(this);
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.service.UpdateMbtoolWithRootTask.java

@Override
public void execute() {
    // If we've reached this point, then the SignedExec upgrade should have failed, but just in
    // case, we'll retry that method.

    boolean ret;/*from   w w  w.  j  a va  2s . co  m*/

    if ((ret = MbtoolConnection.replaceViaSignedExec(getContext()))) {
        Log.v(TAG, "Successfully updated mbtool with SignedExec method");
    } else {
        Log.w(TAG, "Failed to update mbtool with SignedExec method");

        if ((ret = MbtoolConnection.replaceViaRoot(getContext()))) {
            Log.v(TAG, "Successfully updated mbtool with root method");
        } else {
            Log.w(TAG, "Failed to update mbtool with root method");
        }
    }

    Log.d(TAG, "Attempting mbtool connection after update");

    if (ret) {
        MbtoolConnection conn = null;
        try {
            conn = new MbtoolConnection(getContext());
            MbtoolInterface iface = conn.getInterface();
            Log.d(TAG, "mbtool was updated to " + iface.getVersion());
        } catch (Exception e) {
            Log.e(TAG, "Failed to connect to mbtool", e);
            ret = false;
        } finally {
            IOUtils.closeQuietly(conn);
        }
    }

    synchronized (mStateLock) {
        mSuccess = ret;
        sendReply();
        mFinished = true;
    }
}

From source file:org.openschedule.api.impl.EventTemplate.java

public EventTemplate(RestTemplate restTemplate, String apiUrlBase) {
    super(apiUrlBase);
    Log.v(TAG, "initialize : enter");

    this.restTemplate = restTemplate;

    jsonAcceptingHeaders = new LinkedMultiValueMap<String, String>();
    jsonAcceptingHeaders.add("Accept", "application/json");

    Log.v(TAG, "initialize : exit");
}

From source file:com.sharinglabs.cordova.plugin.cache.Cache.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    /*try//from ww  w .ja  v a  2s . com
    {
    */
    if (action.equals("clear")) {
        Log.v(LOG_TAG, "Cordova Android Cache.clear() called.");
        this.callbackContext = callbackContext;

        final Cache self = this;
        cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                try {
                    // clear the cache
                    self.webView.clearCache(true);

                    // clear the data
                    self.clearApplicationData();

                    // send success result to cordova
                    PluginResult result = new PluginResult(PluginResult.Status.OK);
                    result.setKeepCallback(false);
                    self.callbackContext.sendPluginResult(result);
                } catch (Exception e) {
                    String msg = "Error while clearing webview cache.";
                    Log.e(LOG_TAG, msg);

                    // return error answer to cordova
                    PluginResult result = new PluginResult(PluginResult.Status.ERROR, msg);
                    result.setKeepCallback(false);
                    self.callbackContext.sendPluginResult(result);
                }
            }
        });
        return true;
    }
    return false;
    /*
    }
    catch (JSONException e)
    {
    // TODO: signal JSON problem to JS
    //callbackContext.error("Problem with JSON");
    return false;
    }
    */
}

From source file:fr.cph.stock.android.activity.EquityActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "EquityActivity onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.equity_list_activity);
    errorView = (TextView) findViewById(R.id.errorMessage);

    Bundle b = getIntent().getExtras();//  ww w .  ja  v a 2 s  .co m
    Portfolio portfolio = b.getParcelable("portfolio");

    equities = portfolio.getEquities();
    mAdapter = new EquityAdapter(equities, getApplicationContext());
    setListAdapter(mAdapter);

    lastUpdatedView = (TextView) findViewById(R.id.lastUpdated);
    lastUpdatedView.setText(portfolio.getLastUpdate());
    // Set context
    EasyTracker.getInstance().setContext(getApplicationContext());
    // Instantiate the Tracker
    tracker = EasyTracker.getTracker();
}

From source file:org.openschedule.api.impl.OpenScheduleTemplate.java

/**
 * Create a new instance of OpenScheduleTemplate.
 *///from   www  .  j  av a2  s  . c  o  m
public OpenScheduleTemplate(String apiUrlBase) {
    Log.v(TAG, "initialize : enter");

    this.apiUrlBase = apiUrlBase;
    registerOpenScheduleJsonModule();
    getRestTemplate().setErrorHandler(new OpenScheduleErrorHandler());
    initSubApis();

    Log.v(TAG, "initialize : exit");
}

From source file:com.golfmarin.golf.JsonParser.java

public JSONArray getJSONFromFile(Context ctx, String filename, String objects, String object) {
    // This could be a general parser that expects a file containing an objects/object hierarchy
    // This code uses names specific to golfcourses
    InputStream input;//from www.  j  a  v a2  s.co  m
    String jsonString = null;
    JSONObject golfcoursesJson = null;
    JSONObject golfcourseJson = null;
    JSONArray golfcourseJsonArray = null;
    Log.v("mytag", "Started getJSONFromFile:" + filename);
    // Read the file to a string
    try {
        input = ctx.getAssets().open(filename);
        int size = input.available();
        byte[] buffer = new byte[size];
        input.read(buffer);
        input.close();
        jsonString = new String(buffer);
    } catch (Exception e) {
        Log.i("mytag", "Couldn't read json file " + e.toString());
    }

    // Extract JSONArray from string
    try {
        golfcoursesJson = new JSONObject(jsonString);
        golfcourseJson = golfcoursesJson.getJSONObject(objects);
        golfcourseJsonArray = golfcourseJson.getJSONArray(object);
    } catch (JSONException e) {
        Log.i("mytag", "Couldn't parse JSON string." + e);
    }
    return golfcourseJsonArray;
}