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:org.alfresco.mobile.android.application.accounts.oauth.OAuthRefreshTokenCallback.java

@Override
public void onLoadFinished(Loader<LoaderResult<OAuthData>> loader, LoaderResult<OAuthData> results) {
    if (activity != null) {
        OAuthRefreshTokenCallback.saveLastCloudLoadingTime(activity);
        activity.setProgressBarIndeterminateVisibility(false);
    }//w  ww .j  ava2 s. com
    if (!results.hasException()) {
        saveNewOauthData(results);
    } else {
        switch ((int) acc.getTypeId()) {
        case Account.TYPE_ALFRESCO_TEST_OAUTH:
        case Account.TYPE_ALFRESCO_CLOUD:
            CloudExceptionUtils.handleCloudException(activity, results.getException(), true);
            break;
        default:
            break;
        }
        Log.e(TAG, Log.getStackTraceString(results.getException()));
    }
}

From source file:org.alfresco.mobile.android.application.capture.AudioCapture.java

@Override
protected boolean payloadCaptured(int requestCode, int resultCode, Intent data) {
    Uri savedUri = data.getData();/*from w  w  w . j  a  v a 2 s  . co  m*/

    try {
        File folder = parentFolder;
        if (folder != null) {
            String filePath = getAudioFilePathFromUri(savedUri);
            String fileType = getAudioFileTypeFromUri(savedUri);
            String newFilePath = folder.getPath() + "/"
                    + createFilename("AUDIO", filePath.substring(filePath.lastIndexOf(".") + 1));

            copyFile(filePath, newFilePath);

            parentActivity.getContentResolver().delete(savedUri, null, null);
            (new File(filePath)).delete();

            payload = new File(newFilePath);

            if (!fileType.isEmpty()) {
                mimeType = fileType;
            }

            return true;
        } else {
            AlfrescoNotificationManager.getInstance(parentActivity)
                    .showLongToast(parentActivity.getString(R.string.sdinaccessible));
            return false;
        }
    } catch (IOException e) {
        AlfrescoNotificationManager.getInstance(context)
                .showLongToast(context.getString(R.string.cannot_capture));
        Log.d(TAG, Log.getStackTraceString(e));
        return false;
    }
}

From source file:eu.faircode.netguard.Receiver.java

@Override
public void onReceive(final Context context, Intent intent) {
    Log.i(TAG, "Received " + intent);
    Util.logExtras(intent);// ww  w.java  2s . c  om

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) {
        // Application added
        if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
            // Show notification
            if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context) && prefs.getBoolean("install", true)) {
                int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
                notifyNewApplication(uid, context);
            }
        }

    } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
        // Application removed
        Rule.clearCache(context);

        if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) {
            // Remove settings
            String packageName = intent.getData().getSchemeSpecificPart();
            Log.i(TAG, "Deleting settings package=" + packageName);
            context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply();

            int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
            if (uid > 0) {
                DatabaseHelper.getInstance(context).clearAccess(uid, false);

                NotificationManagerCompat.from(context).cancel(uid); // installed notification
                NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification
            }
        }

    } else {
        // Upgrade settings
        upgrade(true, context);

        // Start service
        try {
            if (prefs.getBoolean("enabled", false))
                ServiceSinkhole.start("receiver", context);
            else if (prefs.getBoolean("show_stats", false))
                ServiceSinkhole.run("receiver", context);
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        if (Util.isInteractive(context))
            ServiceSinkhole.reloadStats("receiver", context);
    }
}

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

@Override
public void onReceive(final Context context, Intent intent) {
    Log.i(TAG, "Received " + intent);
    Util.logExtras(intent);//from   w ww  . j ava2  s  .c o  m

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) {
        // Application added
        if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
            // Show notification
            if (true) {
                int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
                notifyNewApplication(uid, context);
            }
        }

    } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
        // Application removed
        Rule.clearCache(context);

        if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) {
            // Remove settings
            String packageName = intent.getData().getSchemeSpecificPart();
            Log.i(TAG, "Deleting settings package=" + packageName);
            context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName)
                    .apply();
            context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply();
            context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply();

            int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
            if (uid > 0) {
                DatabaseHelper.getInstance(context).clearAccess(uid, false);

                NotificationManagerCompat.from(context).cancel(uid); // installed notification
                NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification
            }
        }

    } else {
        // Upgrade settings
        upgrade(true, context);

        // Start service
        try {
            if (prefs.getBoolean("enabled", false))
                ServiceSinkhole.start("receiver", context);
            else if (prefs.getBoolean("show_stats", false))
                ServiceSinkhole.run("receiver", context);
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        if (Util.isInteractive(context))
            ServiceSinkhole.reloadStats("receiver", context);
    }
}

From source file:com.dm.material.dashboard.candybar.fragments.dialog.CreditsFragment.java

private void getData() {
    mGetCredits = new AsyncTask<Void, Void, Boolean>() {

        List<Credit> credits;

        @Override//from w ww. j  ava2s  . c  om
        protected void onPreExecute() {
            super.onPreExecute();
            credits = new ArrayList<>();
        }

        @Override
        protected Boolean doInBackground(Void... voids) {
            while (!isCancelled()) {
                try {
                    Thread.sleep(1);
                    XmlPullParser xpp = getActivity().getResources().getXml(R.xml.contributors);

                    while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) {
                        if (xpp.getEventType() == XmlPullParser.START_TAG) {
                            if (xpp.getName().equals("contributor")) {
                                Credit credit = new Credit(xpp.getAttributeValue(null, "name"),
                                        xpp.getAttributeValue(null, "contribution"),
                                        xpp.getAttributeValue(null, "link"));
                                credits.add(credit);
                            }
                        }
                        xpp.next();
                    }
                    return true;
                } catch (Exception e) {
                    LogUtil.e(Log.getStackTraceString(e));
                    return false;
                }
            }
            return false;
        }

        @Override
        protected void onPostExecute(Boolean aBoolean) {
            super.onPostExecute(aBoolean);
            if (aBoolean) {
                mListView.setAdapter(new CreditsAdapter(getActivity(), credits));
            } else {
                dismiss();
            }
            mGetCredits = null;
        }
    }.execute();
}

From source file:com.example.minhttruong.parsedemo.feature.content.MoviesTab.java

/**
 * get movies data and update refreshing UI
 * default is get Popular Movies/*from   w w w .ja v  a  2 s. c  o m*/
 */
protected void getMovies() {
    Call<MovieRRO> call = getMoviesCall();
    call.enqueue(new Callback<MovieRRO>() {
        @Override
        public void onResponse(Call<MovieRRO> call, Response<MovieRRO> response) {
            updateRefreshState(false);
            // TODO: 10/29/15 check fail code
            if (getMainAct() != null && isVisible() && response.isSuccessful()) {
                mAdapter.setItems(response.body().getResults());
                mAdapter.notifyDataSetChanged();
            }
            Log.d("TEST", "load done");
        }

        @Override
        public void onFailure(Call<MovieRRO> call, Throwable t) {
            Log.d("TEST", "load fail");
            Log.d("TEST", Log.getStackTraceString(t));
            updateRefreshState(false);
        }
    });
}

From source file:jahirfiquitiva.iconshowcase.adapters.IconsAdapter.java

private void iconClick(int position) {
    int resId = iconsList.get(position).getResId();
    String name = iconsList.get(position).getName().toLowerCase(Locale.getDefault());

    if (ShowcaseActivity.iconsPicker) {
        Intent intent = new Intent();
        Bitmap bitmap = null;//from   w ww .  j  a va  2s .  c o m

        try {
            bitmap = BitmapFactory.decodeResource(context.getResources(), resId);
        } catch (Exception e) {
            if (ShowcaseActivity.DEBUGGING)
                Utils.showLog(context, "Icons Picker error: " + Log.getStackTraceString(e));
        }

        if (bitmap != null) {
            intent.putExtra("icon", bitmap);
            intent.putExtra("android.intent.extra.shortcut.ICON_RESOURCE", resId);
            String bmUri = "android.resource://" + context.getPackageName() + "/" + String.valueOf(resId);
            intent.setData(Uri.parse(bmUri));
            context.setResult(Activity.RESULT_OK, intent);
        } else {
            context.setResult(Activity.RESULT_CANCELED, intent);
        }

        context.finish();

    } else {
        if (!inChangelog) {
            Drawable iconDrawable = ContextCompat.getDrawable(context, resId);
            MaterialDialog dialog = new MaterialDialog.Builder(context).customView(R.layout.dialog_icon, false)
                    .title(Utils.makeTextReadable(name)).positiveText(R.string.close)
                    .positiveColor(ColorExtractor.getPreferredColor(iconDrawable, context, true, true)).show();

            if (dialog.getCustomView() != null) {
                ImageView dialogIcon = (ImageView) dialog.getCustomView().findViewById(R.id.dialogicon);
                dialogIcon.setImageResource(resId);
            }
        }
    }
}

From source file:net.olejon.spotcommander.MyTools.java

public String getProjectVersionName() {
    try {//from w ww .  j  av a 2 s.  co m
        return mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionName;
    } catch (Exception e) {
        Log.e("MyTools", Log.getStackTraceString(e));
    }

    return "0.0";
}

From source file:com.nick.scalpel.Scalpel.java

public Scalpel config(Configuration configuration) {
    Configuration usingConfig = configuration == null ? Configuration.DEFAULT : configuration;
    mConfiguration = usingConfig;/*from ww  w .ja  va 2 s .c  om*/
    mLogTag = usingConfig.getLogTag();
    AutoFoundWirer autoFoundWirer = new AutoFoundWirer(usingConfig);
    mFieldWirers.add(autoFoundWirer);
    mFieldWirers.add(new OnClickWirer(autoFoundWirer, usingConfig));
    mFieldWirers.add(new OnTouchWirer(autoFoundWirer, usingConfig));
    mFieldWirers.add(new AutoBindWirer(usingConfig, this));
    mFieldWirers.add(new AutoRegisterWirer(usingConfig, this));
    mFieldWirers.add(new AutoRecycleWirer(usingConfig, this));

    try {
        ServiceManager serviceManager = new DroidServiceManager();
        mFieldWirers.add(new SystemServiceWirer(usingConfig, serviceManager));
    } catch (Exception e) {
        Log.e(usingConfig.getLogTag(), "Failed to init ServiceManager:" + Log.getStackTraceString(e));
    }

    mClassWirers.add(new AutoRequestPermissionWirer(usingConfig));
    mClassWirers.add(new AutoRequestFullScreenWirer(usingConfig, this));
    mClassWirers.add(new AutoRequireRootWirer(usingConfig, new ChrisRootRequester()));
    return this;
}

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

@Override
public void onBindViewHolder(PoisoningsViewHolder viewHolder, int i) {
    try {/*from  w  ww .  j  a  v  a 2  s . c  om*/
        final JSONObject interactionJsonObject = mPoisonings.getJSONObject(i);

        final String type = interactionJsonObject.getString("type");
        final String title = interactionJsonObject.getString("title");
        final String text = interactionJsonObject.getString("text");
        final String uri = interactionJsonObject.getString("uri");

        viewHolder.title.setText(title);
        viewHolder.text.setText(text);

        if (type.equals("helsenorge")) {
            viewHolder.type.setText(mContext.getString(R.string.poisonings_cards_source_helsenorge));
        } else if (type.equals("helsebiblioteket")) {
            viewHolder.type.setText(mContext.getString(R.string.poisonings_cards_source_helsebiblioteket));
        }

        viewHolder.title.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, MainWebViewActivity.class);
                intent.putExtra("title", title);
                intent.putExtra("uri", uri);
                mContext.startActivity(intent);
            }
        });

        viewHolder.buttonUri.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, MainWebViewActivity.class);
                intent.putExtra("title", title);
                intent.putExtra("uri", uri);
                mContext.startActivity(intent);
            }
        });

        animateView(viewHolder.card, i);
    } catch (Exception e) {
        Log.e("PoisoningsCardsAdapter", Log.getStackTraceString(e));
    }
}