Example usage for android.util Log getStackTraceString

List of usage examples for android.util Log getStackTraceString

Introduction

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

Prototype

public static String getStackTraceString(Throwable tr) 

Source Link

Document

Handy function to get a loggable stack trace from a Throwable

Usage

From source file:io.teak.sdk.TeakNotification.java

static void cancel(Context context, int platformId) {
    if (notificationManager == null) {
        try {//from ww  w. j  av a2s .  co  m
            notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        } catch (Exception e) {
            Log.e(LOG_TAG, Log.getStackTraceString(e));
            return;
        }
    }

    if (Teak.isDebug) {
        Log.d(LOG_TAG, "Canceling notification id: " + platformId);
    }

    notificationManager.cancel(NOTIFICATION_TAG, platformId);
    context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));

    Thread updateThread = TeakNotification.notificationUpdateThread.get(platformId);
    if (updateThread != null) {
        updateThread.interrupt();
    }
}

From source file:org.alfresco.mobile.android.api.services.impl.publicapi.PublicAPISiteServiceImpl.java

@Override
protected void retrieveExtraProperties(String personIdentifier) {
    try {//from  www .  j  a v a2s .c o  m
        List<JoinSiteRequestImpl> joinSiteRequestList = new ArrayList<JoinSiteRequestImpl>();
        try {
            joinSiteRequestList = getJoinSiteRequests();
        } catch (Exception e) {
            Log.e(TAG, "Error during cache operation : JoinSiteRequest");
            Log.e(TAG, Log.getStackTraceString(e));
        }

        String link = PublicAPIUrlRegistry.getUserFavoriteSitesUrl(session, personIdentifier);
        List<String> favoriteSites = getSiteIdentifier(new UrlBuilder(link));
        link = PublicAPIUrlRegistry.getUserSitesUrl(session, personIdentifier);
        List<String> userSites = getSiteIdentifier(new UrlBuilder(link));

        retrieveExtraProperties(favoriteSites, userSites, joinSiteRequestList);
    } catch (Exception e) {
        Log.e(TAG, "Error during cache operation. The site object may contains incorrect informations");
        Log.e(TAG, Log.getStackTraceString(e));
    }
}

From source file:net.olejon.mdapp.MedicationActivity.java

@Override
public void onProvideAssistContent(AssistContent assistContent) {
    super.onProvideAssistContent(assistContent);

    try {/*ww  w .  j  a v a  2  s. c  o  m*/
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            String structuredJson = new JSONObject().put("@type", "Drug").put("name", medicationName)
                    .put("activeIngredient", medicationSubstance).put("manufacturer", medicationManufacturer)
                    .toString();

            assistContent.setStructuredData(structuredJson);
        }
    } catch (Exception e) {
        Log.e("MedicationActivity", Log.getStackTraceString(e));
    }
}

From source file:org.alfresco.mobile.android.application.providers.storage.StorageAccessDocumentsProvider.java

@Override
public AssetFileDescriptor openDocumentThumbnail(String documentId, Point sizeHint, CancellationSignal signal)
        throws FileNotFoundException {
    // Log.v(TAG, "openDocumentThumbnail");
    try {//from w w  w  .  j a  va  2 s  .co m
        Node currentNode = null;
        EncodedQueryUri cUri = new EncodedQueryUri(documentId);
        if (cUri.type != PREFIX_DOC) {
            return null;
        }
        checkSession(cUri);

        currentNode = retrieveNode(cUri.id);

        // Let's retrieve the thumbnail
        // Store the document inside a temporary folder per account
        File downloadedFile = null;
        if (getContext() != null && currentNode != null && session != null) {
            File folder = AlfrescoStorageManager.getInstance(getContext()).getTempFolder(selectedAccount);
            if (folder != null) {
                downloadedFile = new File(folder, currentNode.getName());
            }
        } else {
            return null;
        }

        // Is Document in cache ?
        if (downloadedFile.exists()
                && currentNode.getModifiedAt().getTimeInMillis() < downloadedFile.lastModified()) {
            // Document available locally
            ParcelFileDescriptor pfd = ParcelFileDescriptor.open(downloadedFile,
                    ParcelFileDescriptor.MODE_READ_ONLY);
            return new AssetFileDescriptor(pfd, 0, downloadedFile.length());
        }

        // Not in cache so let's download the content !
        ContentStream contentStream = session.getServiceRegistry().getDocumentFolderService()
                .getRenditionStream(currentNode, DocumentFolderService.RENDITION_THUMBNAIL);

        // Check ContentStream
        if (contentStream == null || contentStream.getLength() == 0) {
            return null;
        }

        // Store the thumbnail locally
        copyFile(contentStream.getInputStream(), contentStream.getLength(), downloadedFile, signal);

        // Return the fileDescriptor
        if (downloadedFile.exists()) {
            ParcelFileDescriptor pfd = ParcelFileDescriptor.open(downloadedFile,
                    ParcelFileDescriptor.MODE_READ_ONLY);
            return new AssetFileDescriptor(pfd, 0, downloadedFile.length());
        } else {
            return null;
        }
    } catch (Exception e) {
        Log.w(TAG, Log.getStackTraceString(e));
        return null;
    }
}

From source file:com.vidinoti.pixlive.PixLive.java

private void createARView(final int x, final int y, final int width, final int height, final int ctrlID,
        final boolean insertBelow, final CallbackContext callbackContext) {
    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {

            if (imageSender == null) {
                try {
                    imageSender = new DeviceCameraImageSender();
                } catch (IOException e) {
                    VDARSDKController.log(Log.ERROR, TAG, Log.getStackTraceString(e));
                }//from  w  w w  .  j av  a  2s .  c om

                VDARSDKController.getInstance().setImageSender(imageSender);
            }

            VDARAnnotationView annotationView = new VDARAnnotationView(cordova.getActivity());

            DisplayMetrics displaymetrics = new DisplayMetrics();

            cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);

            annotationView.setVisibility(View.VISIBLE);

            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                    (int) Math.round(width * displaymetrics.scaledDensity),
                    (int) Math.round(height * displaymetrics.scaledDensity));
            params.leftMargin = (int) Math.round(x * displaymetrics.scaledDensity);
            params.topMargin = (int) Math.round(y * displaymetrics.scaledDensity);

            annotationView.setLayoutParams(params);

            touchView.addView(annotationView, 0);

            arViews.put(ctrlID, annotationView);

            VDARSDKController.getInstance().setActivity(cordova.getActivity());

            annotationView.onResume();

        }
    });
}

From source file:it.geosolutions.geocollect.android.core.mission.utils.SQLiteCascadeFeatureLoader.java

private void loadMissionFeature(WKBReader wkbReader, String tableName, String query) {
    Stmt stmt;//w  w w.  j av a2  s  .c  om
    if (Database.complete(query)) {

        try {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "Loading from query: " + query);
            }
            stmt = db.prepare(query);
            MissionFeature f;
            while (stmt.step()) {
                f = new MissionFeature();
                populateFeatureFromStmt(wkbReader, stmt, f);
                f.typeName = tableName;
                mData.add(f);
            }
            stmt.close();

        } catch (Exception e) {
            Log.e(TAG, Log.getStackTraceString(e));
        }

    } else {
        if (BuildConfig.DEBUG) {
            Log.w(TAG, "Query is not complete: " + query);
        }
    }
}

From source file:android_network.hetnet.vpn_service.Util.java

public static StringBuilder readString(InputStreamReader reader) {
    StringBuilder sb = new StringBuilder(2048);
    char[] read = new char[128];
    try {// w w  w.  ja  v a 2  s .c o  m
        for (int i; (i = reader.read(read)) >= 0; sb.append(read, 0, i))
            ;
    } catch (Throwable ex) {
        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
    }
    return sb;
}

From source file:com.davidmascharka.lips.MainActivity.java

private void updateScanResults() {
    if (userInitiatedScan) {
        //Toast.makeText(this, "Scan finished", Toast.LENGTH_SHORT).show();

        resetWifiReadings(building);//from   w  ww .  j av  a  2 s.c o m

        scanResults = wifiManager.getScanResults();
        for (ScanResult result : scanResults) {
            if (wifiReadings.get(result.BSSID) != null) {
                wifiReadings.put(result.BSSID, result.level);
            } else { // BSSID wasn't programmed in - notify user
                //Toast.makeText(this, "This BSSID is new: " + result.BSSID,
                //      Toast.LENGTH_SHORT).show();
            }
        }

        // Get a filehandle for /sdcard/indoor_localization/dataset_BUILDING.txt
        File root = Environment.getExternalStorageDirectory();
        File dir = new File(root.getAbsolutePath() + "/indoor_localization");
        dir.mkdirs();
        File file = new File(dir, "dataset_" + building + ".txt");

        try {
            FileOutputStream outputStream = new FileOutputStream(file, true);
            PrintWriter writer = new PrintWriter(outputStream);

            writer.print(accelerometerX + "," + accelerometerY + "," + accelerometerZ + "," + magneticX + ","
                    + magneticY + "," + magneticZ + "," + light + "," + rotationX + "," + rotationY + ","
                    + rotationZ + "," + orientation[0] + "," + orientation[1] + "," + orientation[2]);

            for (String key : wifiReadings.keySet()) {
                writer.print("," + wifiReadings.get(key));
            }

            if (location != null) {
                writer.print("," + location.getLatitude() + "," + location.getLongitude() + ","
                        + location.getAccuracy());
            } else {
                //@author Mahesh Gaya added permission if-statment
                if (ActivityCompat.checkSelfPermission(this,
                        android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                        || ActivityCompat.checkSelfPermission(this,
                                android.Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
                        || ActivityCompat.checkSelfPermission(this,
                                android.Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
                        || ActivityCompat.checkSelfPermission(this,
                                android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    Log.i(TAG, "Permissions have NOT been granted. Requesting permissions.");
                    requestMyPermissions();
                } else {
                    Log.i(TAG, "Permissions have already been granted. Getting last known location from GPS");
                    location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                }

                if (location != null) {
                    writer.print("," + location.getLatitude() + "," + location.getLongitude() + ","
                            + location.getAccuracy());
                } else {
                    //@author Mahesh Gaya added permission if-statment
                    if (ActivityCompat.checkSelfPermission(this,
                            android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                            || ActivityCompat.checkSelfPermission(this,
                                    android.Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
                            || ActivityCompat.checkSelfPermission(this,
                                    android.Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
                            || ActivityCompat.checkSelfPermission(this,
                                    android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                        Log.i(TAG, "Permissions have NOT been granted. Requesting permissions.");
                        requestMyPermissions();
                    } else {
                        Log.i(TAG,
                                "Permssions have already been granted. Getting last know location from network");
                        location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    }

                    if (location != null) {
                        writer.print("," + location.getLatitude() + "," + location.getLongitude() + ","
                                + location.getAccuracy());
                    } else {
                        Toast.makeText(this, "Location was null", Toast.LENGTH_SHORT).show();
                        writer.print(",?,?,?");
                    }
                }
            }

            TextView xposition = (TextView) findViewById(R.id.text_xposition);
            TextView yposition = (TextView) findViewById(R.id.text_yposition);
            writer.print("," + xposition.getText().toString().substring(3));
            writer.print("," + yposition.getText().toString().substring(3));

            writer.print(" %" + (new Timestamp(System.currentTimeMillis())).toString());

            writer.print("\n\n");

            writer.flush();
            writer.close();

            Toast.makeText(this, "Done saving datapoint", Toast.LENGTH_SHORT).show();
            userInitiatedScan = false;
        } catch (Exception e) {
            Toast.makeText(this, "There was an error", Toast.LENGTH_SHORT).show();
            Log.e("ERROR", Log.getStackTraceString(e));
        }
    }

    Button button = (Button) findViewById(R.id.button_confirm);
    button.setClickable(true);
}

From source file:edu.umich.flowfence.service.Sandbox.java

private void switchSandboxesLocked(CallRecord record, boolean isStarting) {
    if (mCurrentlyRunning != (isStarting ? null : record)) {
        String message = String.format("%s tried to %s executing %s", this, isStarting ? "start" : "finish",
                record);//from w  ww  .ja  v  a2s .co  m
        SandboxInUseException e = new SandboxInUseException(message);
        Log.e(TAG, Log.getStackTraceString(e));
        throw e;
    }
    mCurrentlyRunning = (isStarting ? record : null);
}

From source file:org.alfresco.mobile.android.application.managers.ActionUtils.java

public static boolean actionSendFeedbackEmail(Fragment fr) {
    try {/*from   w w w .j a v a  2 s .c om*/
        ShareCompat.IntentBuilder iBuilder = ShareCompat.IntentBuilder.from(fr.getActivity());
        Context context = fr.getContext();
        // Email
        iBuilder.addEmailTo(context.getResources()
                .getStringArray(org.alfresco.mobile.android.foundation.R.array.bugreport_email));

        // Prepare Subject
        String versionName = context.getPackageManager().getPackageInfo(context.getPackageName(),
                0).versionName;
        int versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;

        String subject = "Alfresco Android Mobile Feedback";
        iBuilder.setSubject(subject);

        // Content
        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        String densityBucket = getDensityString(dm);

        Map<String, String> info = new LinkedHashMap<>();
        info.put("Version", versionName);
        info.put("Version code", Integer.toString(versionCode));
        info.put("Make", Build.MANUFACTURER);
        info.put("Model", Build.MODEL);
        info.put("Resolution", dm.heightPixels + "x" + dm.widthPixels);
        info.put("Density", dm.densityDpi + "dpi (" + densityBucket + ")");
        info.put("Release", Build.VERSION.RELEASE);
        info.put("API", String.valueOf(Build.VERSION.SDK_INT));
        info.put("Language", context.getResources().getConfiguration().locale.getDisplayLanguage());

        StringBuilder builder = new StringBuilder();
        builder.append("\n\n\n\n");
        builder.append("Alfresco Mobile and device details\n");
        builder.append("-------------------\n").toString();
        for (Map.Entry entry : info.entrySet()) {
            builder.append(entry.getKey()).append(": ").append(entry.getValue()).append('\n');
        }

        builder.append("-------------------\n\n").toString();
        iBuilder.setType("message/rfc822");
        iBuilder.setText(builder.toString());
        iBuilder.setChooserTitle(fr.getString(R.string.settings_feedback_email)).startChooser();

        return true;
    } catch (Exception e) {
        AlfrescoNotificationManager.getInstance(fr.getActivity()).showAlertCrouton(fr.getActivity(),
                R.string.error_general);
        Log.d(TAG, Log.getStackTraceString(e));
    }

    return false;
}