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:com.example.android.activityrecognition.CreateMapActivity.java

/**
 * Create a Map and route between User and Car location
 *//*from   w ww. j a va  2s  .c o  m*/
private void setUpMap() {

    try {

        if (mMarkerPoints.size() == 2) {

            // Fetch Car and User coordinates from Marker list
            LatLng carLocation = mMarkerPoints.get(0);

            LatLng curLocation = mMarkerPoints.get(1);

            // Zoom to User location on Google Map
            mMap.moveCamera(CameraUpdateFactory.newLatLng(curLocation));

            mMap.animateCamera(CameraUpdateFactory.zoomTo(12));

            // Draw markers displaying User and Car location tags
            drawMarker(curLocation, "Me");

            drawMarker(carLocation, "Car Location");

            // Create route using car and user location
            createRoute(curLocation, carLocation);
        }

    } catch (Exception e) {
        Log.d("setUpMap failed", e.toString());

        Log.d("BasicDemo's", "STACKTRACE");

        Log.d("BasicDemo's", Log.getStackTraceString(e));
    }
}

From source file:com.dm.wallpaper.board.fragments.dialogs.FilterFragment.java

private void getCategories() {
    mGetCategories = new AsyncTask<Void, Void, Boolean>() {

        List<Category> categories;

        @Override//from   w ww. j  a  v a 2  s.com
        protected Boolean doInBackground(Void... voids) {
            while (!isCancelled()) {
                try {
                    Thread.sleep(1);
                    Database database = Database.get(getActivity());
                    categories = database.getCategories();
                    for (Category category : categories) {
                        int count = database.getCategoryCount(category.getName());
                        category.setCount(count);
                    }
                    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 FilterAdapter(getActivity(), categories, mIsMuzei));
            } else {
                dismiss();
            }
            mGetCategories = null;
        }
    }.execute();
}

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

@Override
protected void onPostExecute(Object result) {
    wakeLock.release();/*from   w  w  w  .j  av  a  2 s.  co m*/
    NotificationManagerCompat.from(context).cancel(ServiceSinkhole.NOTIFY_DOWNLOAD);
    if (result instanceof Throwable) {
        Log.e(TAG, result.toString() + "\n" + Log.getStackTraceString((Throwable) result));
        listener.onException((Throwable) result);
    } else
        listener.onCompleted();
}

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

public FacebookAccessTokenBroadcast(Context context) {
    this.broadcastManager = LocalBroadcastManager.getInstance(context);

    // Get the Facebook SDK Version string
    Class<?> com_facebook_FacebookSdkVersion = null;
    try {//  w  ww.ja  va2  s.c o  m
        com_facebook_FacebookSdkVersion = Class.forName(FACEBOOK_SDK_VERSION_CLASS_NAME);
    } catch (ClassNotFoundException e) {
        Log.e(LOG_TAG, "Facebook SDK not found.");
    }

    Field fbSdkVersionField = null;
    if (com_facebook_FacebookSdkVersion != null) {
        try {
            fbSdkVersionField = com_facebook_FacebookSdkVersion.getDeclaredField("BUILD");
        } catch (NoSuchFieldException e) {
            Log.e(LOG_TAG, "Facebook SDK version field not found.");
        }
    }

    String fbSdkVersion = null;
    if (fbSdkVersionField != null) {
        try {
            fbSdkVersion = fbSdkVersionField.get(null).toString();
            if (Teak.isDebug) {
                Log.d(LOG_TAG, "Facebook SDK version string: " + fbSdkVersion);
            }
        } catch (Exception e) {
            Log.e(LOG_TAG, Log.getStackTraceString(e));
        }
    }

    if (fbSdkVersion != null) {
        String[] fbSDKs = fbSdkVersion.split("/");
        String[] versionStrings = fbSDKs[0].split("\\.");
        int[] versionInts = new int[versionStrings.length];
        for (int i = 0; i < versionStrings.length; i++) {
            versionInts[i] = Integer.parseInt(versionStrings[i]);
        }

        switch (versionInts[0]) {
        case 3: {
            if (Teak.isDebug) {
                Log.d(LOG_TAG, "Listening for Facebook SDK 3.x broadcast actions.");
            }

            Class<?> com_facebook_Session;
            try {
                com_facebook_Session = Class.forName(FACEBOOK_3_x_SESSION_CLASS_NAME);
                if (Teak.isDebug) {
                    Log.d(LOG_TAG, "Found " + com_facebook_Session.toString());
                }

                this.com_facebook_Session_getActiveSession = com_facebook_Session.getMethod("getActiveSession");
                try {
                    this.com_facebook_Session_getAccessToken = com_facebook_Session.getMethod("getAccessToken");
                } catch (NoSuchMethodException e) {
                    Log.e(LOG_TAG, FACEBOOK_3_x_SESSION_CLASS_NAME + ".getAccessToken() not found: "
                            + Log.getStackTraceString(e));
                }

                Field f = com_facebook_Session.getDeclaredField(FACEBOOK_3_x_BROADCAST_ACTION_FIELD);
                this.facebook_3_x_BroadcastAction = (String) f.get(null);
                if (Teak.isDebug) {
                    Log.d(LOG_TAG, "Found broadcast action: " + this.facebook_3_x_BroadcastAction);
                }
            } catch (ClassNotFoundException e) {
                Log.e(LOG_TAG, FACEBOOK_3_x_SESSION_CLASS_NAME + " not found.");
            } catch (NoSuchMethodException e) {
                Log.e(LOG_TAG, FACEBOOK_3_x_SESSION_CLASS_NAME + ".getActiveSession() not found: "
                        + Log.getStackTraceString(e));
            } catch (Exception e) {
                Log.e(LOG_TAG,
                        "Error occured working with reflected Facebook SDK: " + Log.getStackTraceString(e));
            }

            if (this.com_facebook_Session_getActiveSession != null
                    && this.com_facebook_Session_getAccessToken != null
                    && this.facebook_3_x_BroadcastAction != null) {
                IntentFilter filter = new IntentFilter();
                filter.addAction(this.facebook_3_x_BroadcastAction);

                this.broadcastManager.registerReceiver(this.broadcastReceiver, filter);
            }
        }
            break;

        case 4: {
            Class<?> com_facebook_AccessToken;
            try {
                com_facebook_AccessToken = Class.forName(FACEBOOK_4_x_ACCESS_TOKEN_CLASS_NAME);
                if (Teak.isDebug) {
                    Log.d(LOG_TAG, "Found " + com_facebook_AccessToken.toString());
                }

                this.com_facebook_AccessToken_getToken = com_facebook_AccessToken.getMethod("getToken");
            } catch (ClassNotFoundException e) {
                Log.e(LOG_TAG, FACEBOOK_4_x_ACCESS_TOKEN_CLASS_NAME + " not found.");
            } catch (NoSuchMethodException e) {
                Log.e(LOG_TAG, FACEBOOK_4_x_ACCESS_TOKEN_CLASS_NAME + ".getToken() not found: "
                        + Log.getStackTraceString(e));
            } catch (Exception e) {
                Log.e(LOG_TAG,
                        "Error occured working with reflected Facebook SDK: " + Log.getStackTraceString(e));
            }

            try {
                Class<?> com_facebook_AccessTokenManager;
                com_facebook_AccessTokenManager = Class.forName(FACEBOOK_4_x_ACCESS_TOKEN_MANAGER_CLASS_NAME);
                if (Teak.isDebug) {
                    Log.d(LOG_TAG, "Found " + com_facebook_AccessTokenManager.toString());
                }

                Field f = com_facebook_AccessTokenManager.getDeclaredField(FACEBOOK_4_x_BROADCAST_ACTION_FIELD);
                f.setAccessible(true);
                this.facebook_4_x_BroadcastAction = (String) f.get(null);
                if (Teak.isDebug) {
                    Log.d(LOG_TAG, "Found broadcast action: " + this.facebook_4_x_BroadcastAction);
                }
            } catch (ClassNotFoundException e) {
                Log.e(LOG_TAG, FACEBOOK_4_x_ACCESS_TOKEN_MANAGER_CLASS_NAME + " not found.");
            } catch (Exception e) {
                Log.e(LOG_TAG,
                        "Error occured working with reflected Facebook SDK: " + Log.getStackTraceString(e));
            }

            if (this.com_facebook_AccessToken_getToken != null && this.facebook_4_x_BroadcastAction != null) {
                IntentFilter filter = new IntentFilter();
                filter.addAction(this.facebook_4_x_BroadcastAction);

                this.broadcastManager.registerReceiver(this.broadcastReceiver, filter);
            }
        }
            break;

        default: {
            Log.e(LOG_TAG, "Don't know how to use Facebook SDK version " + versionInts[0]);
        }
        }
    }
}

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

private void filterSearch(String query) {
    try {/*  ww w .  j  av a2  s . c  o  m*/
        mAdapter.search(query);
        if (mAdapter.getFaqsCount() == 0) {
            String text = String.format(getActivity().getResources().getString(R.string.search_noresult),
                    query);
            mSearchResult.setText(text);
            mSearchResult.setVisibility(View.VISIBLE);
        } else
            mSearchResult.setVisibility(View.GONE);
    } catch (Exception e) {
        LogUtil.e(Log.getStackTraceString(e));
    }
}

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

@Override
public void onMapReady(final GoogleMap googleMap) {
    googleMap.setMyLocationEnabled(true);

    try {/*  w  w w. ja v  a 2  s  .co m*/
        mTools.showToast(getString(R.string.pharmacies_location_map_locating), 0);

        RequestQueue requestQueue = Volley.newRequestQueue(mContext);

        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,
                getString(R.string.project_website_uri) + "api/1/geocode/?address="
                        + URLEncoder.encode(mPharmacyAddress, "utf-8"),
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        try {
                            double latitude = response.getDouble("latitude");
                            double longitude = response.getDouble("longitude");

                            googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude))
                                    .title(mPharmacyName));
                            googleMap.moveCamera(
                                    CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 16));
                        } catch (Exception e) {
                            mTools.showToast(
                                    getString(R.string.pharmacies_location_map_exact_location_not_found), 1);

                            Log.e("PharmaciesLocationMap", Log.getStackTraceString(e));

                            finish();
                        }
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        mTools.showToast(getString(R.string.pharmacies_location_map_exact_location_not_found),
                                1);

                        Log.e("PharmaciesLocationMap", error.toString());

                        finish();
                    }
                });

        jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

        requestQueue.add(jsonObjectRequest);
    } catch (Exception e) {
        Log.e("PharmaciesLocationMap", Log.getStackTraceString(e));
    }
}

From source file:com.master.metehan.filtereagle.ActivityPro.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "Create");
    Util.setTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pro);//from   www  . j  av a  2  s.c  om

    getSupportActionBar().setTitle(R.string.title_pro);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    // Initial state
    updateState();

    TextView tvLogTitle = (TextView) findViewById(R.id.tvLogTitle);
    TextView tvFilterTitle = (TextView) findViewById(R.id.tvFilterTitle);
    TextView tvNotifyTitle = (TextView) findViewById(R.id.tvNotifyTitle);
    TextView tvSpeedTitle = (TextView) findViewById(R.id.tvSpeedTitle);
    TextView tvThemeTitle = (TextView) findViewById(R.id.tvThemeTitle);
    TextView tvAllTitle = (TextView) findViewById(R.id.tvAllTitle);

    Linkify.TransformFilter filter = new Linkify.TransformFilter() {
        @Override
        public String transformUrl(Matcher match, String url) {
            return "";
        }
    };

    Linkify.addLinks(tvLogTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_LOG, null, filter);
    Linkify.addLinks(tvFilterTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_FILTER, null,
            filter);
    Linkify.addLinks(tvNotifyTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_NOTIFY, null,
            filter);
    Linkify.addLinks(tvSpeedTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SPEED, null, filter);
    Linkify.addLinks(tvThemeTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_THEME, null, filter);
    Linkify.addLinks(tvAllTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_PRO1, null, filter);

    // Challenge
    TextView tvChallenge = (TextView) findViewById(R.id.tvChallenge);
    tvChallenge.setText(Build.SERIAL);

    // Response
    try {
        final String response = Util.md5(Build.SERIAL, "FilterEagle");
        EditText etResponse = (EditText) findViewById(R.id.etResponse);
        etResponse.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                // Do nothing
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // Do nothing
            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (response.equals(editable.toString().toUpperCase())) {
                    IAB.setBought(SKU_DONATION, ActivityPro.this);
                    updateState();
                }
            }
        });
    } catch (Throwable ex) {
        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
    }

    try {
        iab = new IAB(new IAB.Delegate() {
            @Override
            public void onReady(final IAB iab) {
                Log.i(TAG, "IAB ready");
                try {
                    iab.updatePurchases();
                    updateState();

                    final Button btnLog = (Button) findViewById(R.id.btnLog);
                    final Button btnFilter = (Button) findViewById(R.id.btnFilter);
                    final Button btnNotify = (Button) findViewById(R.id.btnNotify);
                    final Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
                    final Button btnTheme = (Button) findViewById(R.id.btnTheme);
                    final Button btnAll = (Button) findViewById(R.id.btnAll);

                    View.OnClickListener listener = new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            try {
                                PendingIntent pi = null;
                                if (view == btnLog)
                                    pi = iab.getBuyIntent(SKU_LOG);
                                else if (view == btnFilter)
                                    pi = iab.getBuyIntent(SKU_FILTER);
                                else if (view == btnNotify)
                                    pi = iab.getBuyIntent(SKU_NOTIFY);
                                else if (view == btnSpeed)
                                    pi = iab.getBuyIntent(SKU_SPEED);
                                else if (view == btnTheme)
                                    pi = iab.getBuyIntent(SKU_THEME);
                                else if (view == btnAll)
                                    pi = iab.getBuyIntent(SKU_PRO1);

                                if (pi != null)
                                    startIntentSenderForResult(pi.getIntentSender(), view.getId(), new Intent(),
                                            0, 0, 0);
                            } catch (Throwable ex) {
                                Log.i(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                                Util.sendCrashReport(ex, ActivityPro.this);
                            }
                        }
                    };

                    btnLog.setOnClickListener(listener);
                    btnFilter.setOnClickListener(listener);
                    btnNotify.setOnClickListener(listener);
                    btnSpeed.setOnClickListener(listener);
                    btnTheme.setOnClickListener(listener);
                    btnAll.setOnClickListener(listener);

                    btnLog.setEnabled(true);
                    btnFilter.setEnabled(true);
                    btnNotify.setEnabled(true);
                    btnSpeed.setEnabled(true);
                    btnTheme.setEnabled(true);
                    btnAll.setEnabled(true);

                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
            }
        }, this);
        iab.bind();
    } catch (Throwable ex) {
        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
    }
}

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

@Override
public void onBindViewHolder(CategoryViewHolder viewHolder, int i) {
    try {/*w  ww .ja  v a  2 s.  c  om*/
        final JSONObject categoriesJsonObject = mCategories.getJSONObject(i);

        viewHolder.card.setCardBackgroundColor(Color.parseColor(mColor));

        switch (mIcon) {
        case "lvh_urgent": {
            viewHolder.icon.setImageResource(R.drawable.ic_favorite_white_24dp);
            break;
        }
        case "lvh_symptoms": {
            viewHolder.icon.setImageResource(R.drawable.ic_stethoscope);
            break;
        }
        case "lvh_injuries": {
            viewHolder.icon.setImageResource(R.drawable.ic_healing_white_24dp);
            break;
        }
        case "lvh_administrative": {
            viewHolder.icon.setImageResource(R.drawable.ic_my_library_books_white_24dp);
            break;
        }
        }

        viewHolder.title.setText(categoriesJsonObject.getString("title"));

        viewHolder.categories.removeAllViews();

        final JSONArray itemsJsonArray = categoriesJsonObject.getJSONArray("items");

        for (int f = 0; f < itemsJsonArray.length(); f++) {
            final JSONObject categoryJsonObject = itemsJsonArray.getJSONObject(f);

            final String name = categoryJsonObject.getString("name");
            final String uri = categoryJsonObject.getString("uri");

            TextView textView = (TextView) mLayoutInflater
                    .inflate(R.layout.activity_lvh_categories_card_categories_item, null);
            textView.setText(name);

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

            viewHolder.categories.addView(textView);
        }

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

From source file:eu.faircode.adblocker.ActivityPro.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "Create");
    Util.setTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pro);/*  w w  w  .j a v  a 2 s. co m*/

    getSupportActionBar().setTitle(R.string.title_pro);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    // Initial state
    updateState();

    TextView tvLogTitle = (TextView) findViewById(R.id.tvLogTitle);
    TextView tvFilterTitle = (TextView) findViewById(R.id.tvFilterTitle);
    TextView tvNotifyTitle = (TextView) findViewById(R.id.tvNotifyTitle);
    TextView tvSpeedTitle = (TextView) findViewById(R.id.tvSpeedTitle);
    TextView tvThemeTitle = (TextView) findViewById(R.id.tvThemeTitle);
    TextView tvAllTitle = (TextView) findViewById(R.id.tvAllTitle);

    Linkify.TransformFilter filter = new Linkify.TransformFilter() {
        @Override
        public String transformUrl(Matcher match, String url) {
            return "";
        }
    };

    Linkify.addLinks(tvLogTitle, Pattern.compile(".*"), "http://www.adblocker.me/#" + SKU_LOG, null, filter);
    Linkify.addLinks(tvFilterTitle, Pattern.compile(".*"), "http://www.adblocker.me/#" + SKU_FILTER, null,
            filter);
    Linkify.addLinks(tvNotifyTitle, Pattern.compile(".*"), "http://www.adblocker.me/#" + SKU_NOTIFY, null,
            filter);
    Linkify.addLinks(tvSpeedTitle, Pattern.compile(".*"), "http://www.adblocker.me/#" + SKU_SPEED, null,
            filter);
    Linkify.addLinks(tvThemeTitle, Pattern.compile(".*"), "http://www.adblocker.me/#" + SKU_THEME, null,
            filter);
    Linkify.addLinks(tvAllTitle, Pattern.compile(".*"), "http://www.adblocker.me/#" + SKU_PRO1, null, filter);

    // Challenge
    TextView tvChallenge = (TextView) findViewById(R.id.tvChallenge);
    tvChallenge.setText(Build.SERIAL);

    // Response
    try {
        final String response = Util.md5(Build.SERIAL, "NetGuard");
        EditText etResponse = (EditText) findViewById(R.id.etResponse);
        etResponse.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                // Do nothing
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // Do nothing
            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (response.equals(editable.toString().toUpperCase())) {
                    IAB.setBought(SKU_DONATION, ActivityPro.this);
                    updateState();
                }
            }
        });
    } catch (Throwable ex) {
        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
    }

    try {
        iab = new IAB(new IAB.Delegate() {
            @Override
            public void onReady(final IAB iab) {
                Log.i(TAG, "IAB ready");
                try {
                    iab.updatePurchases();
                    updateState();

                    final Button btnLog = (Button) findViewById(R.id.btnLog);
                    final Button btnFilter = (Button) findViewById(R.id.btnFilter);
                    final Button btnNotify = (Button) findViewById(R.id.btnNotify);
                    final Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
                    final Button btnTheme = (Button) findViewById(R.id.btnTheme);
                    final Button btnAll = (Button) findViewById(R.id.btnAll);

                    View.OnClickListener listener = new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            try {
                                PendingIntent pi = null;
                                if (view == btnLog)
                                    pi = iab.getBuyIntent(SKU_LOG);
                                else if (view == btnFilter)
                                    pi = iab.getBuyIntent(SKU_FILTER);
                                else if (view == btnNotify)
                                    pi = iab.getBuyIntent(SKU_NOTIFY);
                                else if (view == btnSpeed)
                                    pi = iab.getBuyIntent(SKU_SPEED);
                                else if (view == btnTheme)
                                    pi = iab.getBuyIntent(SKU_THEME);
                                else if (view == btnAll)
                                    pi = iab.getBuyIntent(SKU_PRO1);

                                if (pi != null)
                                    startIntentSenderForResult(pi.getIntentSender(), view.getId(), new Intent(),
                                            0, 0, 0);
                            } catch (Throwable ex) {
                                Log.i(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                                Util.sendCrashReport(ex, ActivityPro.this);
                            }
                        }
                    };

                    btnLog.setOnClickListener(listener);
                    btnFilter.setOnClickListener(listener);
                    btnNotify.setOnClickListener(listener);
                    btnSpeed.setOnClickListener(listener);
                    btnTheme.setOnClickListener(listener);
                    btnAll.setOnClickListener(listener);

                    btnLog.setEnabled(true);
                    btnFilter.setEnabled(true);
                    btnNotify.setEnabled(true);
                    btnSpeed.setEnabled(true);
                    btnTheme.setEnabled(true);
                    btnAll.setEnabled(true);

                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
            }
        }, this);
        iab.bind();
    } catch (Throwable ex) {
        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
    }
}

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

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == MEDICATION_REQUEST_CODE && data != null) {
        if (resultCode == RESULT_OK) {
            String name = data.getStringExtra("name");
            String manufacturer = data.getStringExtra("manufacturer");

            try {
                JSONObject patientMedicationJsonObject = new JSONObject(
                        "{\"name\":\"" + name + "\",\"manufacturer\":\"" + manufacturer + "\"}");

                mPatientMedicationsJsonArray.put(patientMedicationJsonObject);

                getMedications();//from  w ww . j av a2s.com
            } catch (Exception e) {
                Log.e("NotesEditActivity", Log.getStackTraceString(e));
            }
        }
    }
}