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.Amazon.java

public void init(Context context) {
    skuDetailsRequestMap = new HashMap<>();
    skuPriceMap = new HashMap<>();
    try {/*from   w  ww  .ja  va2s  .  c o  m*/
        Class<?> purchasingListenerClass = Class.forName("com.amazon.device.iap.PurchasingListener");
        InvocationHandler handler = new PurchasingListenerInvocationHandler();
        Object proxy = Proxy.newProxyInstance(purchasingListenerClass.getClassLoader(),
                new Class[] { purchasingListenerClass }, handler);

        Class<?> purchasingServiceClass = Class.forName("com.amazon.device.iap.PurchasingService");
        Method m = purchasingServiceClass.getMethod("registerListener", Context.class, purchasingListenerClass);
        m.invoke(null, context, proxy);

        if (Teak.isDebug) {
            Field sandbox = purchasingServiceClass.getDeclaredField("IS_SANDBOX_MODE");

            Log.d(LOG_TAG, "Amazon In-App Purchasing 2.0 registered.");
            Log.d(LOG_TAG, "   Sandbox Mode: " + sandbox.getBoolean(null));
        }
    } catch (Exception e) {
        Log.e(LOG_TAG, "Reflection error: " + Log.getStackTraceString(e));
        Teak.sdkRaven.reportException(e);
    }
}

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

public DebugConfiguration(@NonNull Context context) {
    SharedPreferences tempPreferences = null;
    try {/*from  w  ww .  j a  v a 2  s. co  m*/
        tempPreferences = context.getSharedPreferences(Teak.PREFERENCES_FILE, Context.MODE_PRIVATE);
    } catch (Exception e) {
        Log.e(LOG_TAG, "Error calling getSharedPreferences(). " + Log.getStackTraceString(e));
    } finally {
        this.preferences = tempPreferences;
    }

    if (this.preferences == null) {
        Log.e(LOG_TAG, "getSharedPreferences() returned null. Some debug functionality is disabled.");
        this.forceDebug = false;
    } else {
        this.forceDebug = this.preferences.getBoolean(PREFERENCE_FORCE_DEBUG, false);
    }
}

From source file:info.papdt.blacklight.api.friendships.GroupsApi.java

public static void addMemberToGroup(String uid, String groupId) {
    WeiboParameters params = new WeiboParameters();
    params.put("uid", uid);
    params.put("list_id", groupId);

    try {/*  ww w .  j  a  v a  2  s  .  c o m*/
        request(Constants.FRIENDSHIPS_GROUPS_MEMBERS_ADD, params, HTTP_POST);
    } catch (Exception e) {
        if (DEBUG) {
            Log.e(TAG, "Cannot add user to group");
            Log.e(TAG, Log.getStackTraceString(e));
        }
    }
}

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

public static void requestConfigurationForApp(final Session session) {
    HashMap<String, Object> payload = new HashMap<>();
    payload.put("id", session.appConfiguration.appId);

    new Thread(new Request("gocarrot.com", "/games/" + session.appConfiguration.appId + "/settings.json",
            payload, session) {// w w w. j  ava2 s.c  o  m
        @Override
        protected void done(int responseCode, String responseBody) {
            try {
                JSONObject response = new JSONObject(responseBody);

                RemoteConfiguration configuration = new RemoteConfiguration(session.appConfiguration,
                        response.isNull("auth") ? "gocarrot.com" : response.getString("auth"),
                        nullInsteadOfEmpty(response.isNull("sdk_sentry_dsn") ? null
                                : response.getString("sdk_sentry_dsn")),
                        nullInsteadOfEmpty(response.isNull("app_sentry_dsn") ? null
                                : response.getString("app_sentry_dsn")));

                synchronized (eventListenersMutex) {
                    for (EventListener e : RemoteConfiguration.eventListeners) {
                        e.onConfigurationReady(configuration);
                    }
                }
            } catch (Exception e) {
                Log.e(LOG_TAG, "Error processing settings.json " + Log.getStackTraceString(e));
            }
        }
    }).start();
}

From source file:org.alfresco.mobile.android.application.operations.batch.account.CreateAccountCallBack.java

@Override
public void onError(Operation<Account> task, Exception e) {
    Log.d(TAG, Log.getStackTraceString(e));

    Bundle b = new Bundle();
    b.putInt(SimpleAlertDialogFragment.PARAM_ICON, R.drawable.ic_alfresco_logo);
    b.putInt(SimpleAlertDialogFragment.PARAM_TITLE, R.string.error_session_creation_title);
    b.putInt(SimpleAlertDialogFragment.PARAM_POSITIVE_BUTTON, android.R.string.ok);
    b.putInt(SimpleAlertDialogFragment.PARAM_MESSAGE, SessionExceptionHelper.getMessageId(context, e));
    ActionManager.actionDisplayDialog(context, b);

    if (task instanceof CreateAccountThread && ((CreateAccountThread) task).getOauthData() != null) {
        LocalBroadcastManager.getInstance(context)
                .sendBroadcast(new Intent(IntentIntegrator.ACTION_CREATE_ACCOUNT_CLOUD_ERROR));
    }/*w w  w  .j av  a2 s.  c  om*/

    super.onError(task, e);
}

From source file:kaist.cs492c_2015.washerbrowser.MyGcmListenerService.java

/**
 * Called when message is received./*w  ww  .  j  a v a 2 s  .  co m*/
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
    String message = data.getString("message");
    Log.i("MESSAGE", message);
    if (from.startsWith("/topics/")) {
        // message received from some topic.
    } else {
        // normal downstream message.
    }

    // [START_EXCLUDE]
    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */

    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */

    String id = "";
    String floor = "";
    String dorm = "";
    try {
        JSONObject jsonObject = new JSONObject(message);
        id = jsonObject.getString("id");
        floor = jsonObject.getString("floor");
        dorm = jsonObject.getString("dorm");
    } catch (JSONException e) {
        Log.getStackTraceString(e);
    }

    mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    SharedPreferences.Editor editor = mPref.edit();
    editor.putBoolean(id, false);
    editor.commit();
    String leftRight = "Left";
    if (Integer.parseInt(id) % 2 == 0) {
        leftRight = "Right";
    }
    String msg = dorm.toUpperCase() + " " + floor + "F " + leftRight + " is Available!";
    sendNotification(msg);
    // [END_EXCLUDE]
}

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

/**
 * Initialize Teak and tell it to listen to the lifecycle events of {@link Activity}.
 * <p/>// w w  w.  j av  a  2 s  . c om
 * <p>Call this function from the {@link Activity#onCreate} function of your <code>Activity</code>
 * <b>before</b> the call to <code>super.onCreate()</code></p>
 *
 * @param activity The main <code>Activity</code> of your app.
 */
public static void onCreate(Activity activity) {
    Log.d(LOG_TAG, "Android SDK Version: " + Teak.SDKVersion);

    if (activity == null) {
        Log.e(LOG_TAG, "null Activity passed to onCreate, Teak is disabled.");
        Teak.setState(State.Disabled);
        return;
    }

    {
        String airSdkVersion = Helpers.getStringResourceByName("io_teak_air_sdk_version",
                activity.getApplicationContext());
        if (airSdkVersion != null) {
            Log.d(LOG_TAG, "Adobe AIR SDK Version: " + airSdkVersion);
        }
    }

    // Set up debug logging ASAP
    try {
        final Context context = activity.getApplicationContext();
        final ApplicationInfo applicationInfo = context.getApplicationInfo();
        Teak.debugConfiguration = new DebugConfiguration(context);
        Teak.isDebug = Teak.forceDebug || Teak.debugConfiguration.forceDebug || (applicationInfo != null
                && (0 != (applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE)));
    } catch (Exception e) {
        Log.e(LOG_TAG, "Error creating DebugConfiguration. " + Log.getStackTraceString(e));
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        Log.e(LOG_TAG, "Teak requires API level 14 to operate. Teak is disabled.");
        Teak.setState(State.Disabled);
    } else {
        try {
            Application application = activity.getApplication();
            synchronized (Teak.stateMutex) {
                if (Teak.state == State.Allocated) {
                    application.registerActivityLifecycleCallbacks(Teak.lifecycleCallbacks);
                }
            }
        } catch (Exception e) {
            Log.e(LOG_TAG, "Failed to register Activity lifecycle callbacks. Teak is disabled. "
                    + Log.getStackTraceString(e));
            Teak.setState(State.Disabled);
        }
    }
}

From source file:com.thesis.asa.resourcemvc.ResourceActivity.java

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    Intent intent = getIntent();/*w w  w  .ja va  2  s.c  o m*/
    Bundle extras = intent.getExtras();
    String name = extras.getString(SlidePageFragment.RESOURCE);
    try {

        resource = (Resource) Class.forName(name).getDeclaredConstructor(Context.class).newInstance(this);
        view = (ResourceView) Class.forName(name + "View")
                .getDeclaredConstructor(ResourceActivity.class, Resource.class).newInstance(this, resource);
    } catch (Exception e) {
        Log.d(Utilities.ERROR, "ERROR AT LOADING CLASS OR CLASS OBJECT INITIALIZATION" + name + "View");
        Log.d(Utilities.ERROR, Log.getStackTraceString(e));
    }

    loadIntent(extras);

    // Sets the View Layer
    view.showResourceViewIn();

    loadSettings();

    Button apply = (Button) findViewById(R.id.applyButton);
    OnClickListener controller = getController();
    apply.setOnClickListener(controller);

    Button cancel = (Button) findViewById(R.id.cancelButton);
    cancel.setOnClickListener(controller);
}

From source file:org.alfresco.mobile.android.application.operations.batch.account.LoadSessionCallBack.java

@Override
public void onError(Operation<AlfrescoSession> task, Exception e) {
    LoadSessionThread loadingTask = ((LoadSessionThread) task);
    Log.e(TAG, Log.getStackTraceString(e));

    switch (loadingTask.getAccount().getTypeId()) {
    case Account.TYPE_ALFRESCO_TEST_OAUTH:
    case Account.TYPE_ALFRESCO_CLOUD:
        saveData(task, null);/*  w  w w  . j  a v a 2 s.  c o m*/
        Account acc = loadingTask.getAccount();
        if (acc.getActivation() == null) {
            CloudExceptionUtils.handleCloudException(context, loadingTask.getAccount().getId(), e, true);
        } else {
            Intent broadcastIntent = new Intent(IntentIntegrator.ACTION_ACCOUNT_INACTIVE);
            broadcastIntent.putExtra(IntentIntegrator.ACTION_ACCOUNT_INACTIVE, true);
            LocalBroadcastManager.getInstance(context).sendBroadcast(broadcastIntent);
        }
        break;
    case Account.TYPE_ALFRESCO_TEST_BASIC:
    case Account.TYPE_ALFRESCO_CMIS:
        Intent broadcastIntent = new Intent();
        broadcastIntent.setAction(IntentIntegrator.ACTION_LOAD_ACCOUNT_ERROR);
        broadcastIntent.putExtra(SimpleAlertDialogFragment.PARAM_ICON, R.drawable.ic_alfresco_logo);
        broadcastIntent.putExtra(SimpleAlertDialogFragment.PARAM_TITLE,
                R.string.error_session_creation_message);
        broadcastIntent.putExtra(SimpleAlertDialogFragment.PARAM_POSITIVE_BUTTON, android.R.string.ok);
        broadcastIntent.putExtra(SimpleAlertDialogFragment.PARAM_MESSAGE,
                SessionExceptionHelper.getMessageId(context, e));
        if (loadingTask.getAccount() != null) {
            broadcastIntent.putExtra(IntentIntegrator.EXTRA_ACCOUNT_ID, loadingTask.getAccount().getId());
        }
        LocalBroadcastManager.getInstance(context).sendBroadcast(broadcastIntent);
        break;
    default:
        break;
    }
    super.onError(task, e);
}

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

@Override
public boolean captureData() {
    if (hasDevice()) {
        try {//from  w  w w . j av a  2  s .c o m
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            if (intent.resolveActivity(context.getPackageManager()) == null) {
                AlfrescoNotificationManager.getInstance(context).showAlertCrouton(parentActivity,
                        context.getString(R.string.feature_disable));
                return false;
            }

            File folder = parentFolder;
            if (folder != null) {
                payload = new File(folder.getPath(), createFilename("IMG_", "jpg"));

                intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(payload));

                parentActivity.startActivityForResult(intent, getRequestCode());
            } else {
                AlfrescoNotificationManager.getInstance(parentActivity)
                        .showLongToast(parentActivity.getString(R.string.sdinaccessible));
            }
        } catch (Exception e) {
            Log.d(TAG, Log.getStackTraceString(e));
            return false;
        }

        return true;
    } else {
        return false;
    }
}