Android: crash reports libs and services

Posted by Unknown Rabu, 29 Agustus 2012 0 komentar

The world is not ideal. And even the best tested applications crashes sometimes.
That is why it's important to receive detailed crash reports to find the crash reason and fix it!
Leaving your users with crashes alone, while developers don't even know about crashes - is the worst case scenario! You should always be in touch with users to provide the best user experience.




So how we will make it?
Well, you may know that Android 2.2 Froyo introduced a bug report feature. Developers will receive freeze and crash reports from their apps. It looks something like this:



When app crashes Android run-time will pop-up dialog with option to send report about what happens.
Well, it's definitely not bad. But user may just skip it by pressing "Force close" button. And we also need to support our users with pre Android 2.2 devices.

So in this article I want to list several libs and services that may be useful for crash reports handling.



1) ACRA http://code.google.com/p/acra
I suppose it was one of the first solution for Android apps (SDK v1.5+ support) to handle crashes. It's free and open source! :) And now it's very mature and has a lot of great options:

  • configurable user interaction (silent reports, Toast notification, status bar notification + dialog)
  • detailed crash reports
  • ability to add your own variables content or debug traces
  • send error reports even if the application doesn't crash
  • and more!

All you need to do is to add small jar file to your project, configure it a little bit (usually which data to send and where to send) and that's it! Now next time app crashes, you will know about it and there will be details (such as phone vendor, model, stack-trace, etc.) about it.
Finally, I like ACRA a lot and it's my favorite tool for handling crash reports. ACRA is great, really!


Then, why do we need to talk about other tools if ACRA is so great?
First of all, variety is good. In the second place, you definitely will need some front-end to view and analyse all reports. But ACRA is just a library. Yes, ACRA can submit reports to Google Docs spreadsheets, but you may find it a little bit tedious to use.

So below there are tools and services that provide nice front-ends to visualize crash reports. Some of them has their own libraries (e.g. Crittercism), some of them can be integrated with ACRA (e.g. Bugsense or HockeyApp).
Most of them are paid (not all, e.g. Bugsnag actually is in free beta) but has free limited plans also.

2) Crittercism (crash reporting and customer support SDK for iOS and Android apps) 
http://www.crittercism.com 

3) BugSense (tool that collects and analyzes crash reports from mobile apps)
http://www.bugsense.com

4) Bugsnag (helps capture exceptions in real-time from web, mobile and desktop applications)
https://bugsnag.com

5) Logentries (log management and analysis service)
https://logentries.com/
Instructions how to collection data from ACRA:
http://www.vaudaux-ruth.com/android-log-collecting-with-acra-and-logentries

6) HockeyApp (provides the way to distribute app betas and collect live crash reports for beta and release apps on Mac OS X, iOS and Android)
http://www.hockeyapp.net
Instructions how to wire up HockeyApp with ACRA:
http://support.hockeyapp.net/kb/client-integration-android/how-to-use-acra-with-hockeyapp

7) Zibhium (a platform for Android beta distribution, real time crash analytics, with a built in support desk)
https://www.zubhium.com

If you know some other tools or services that can be helpful with app crash reports handling, then give me to know. I will add them to the list! ;-)


Baca Selengkapnya ....

Android: WebView tips & tricks

Posted by Unknown Senin, 20 Agustus 2012 0 komentar
WebView is one of the most useful view component in Android SDK.
In fact, if you want to display complex HTML content (for simple HTML formatting TextView is enough), add JavaScript support to it, etc., the only choice you have is to use WebView component to handle all that stuff. Moreover, WebView can be configured to support pinch-to-zoom, custom URL handling, etc.
As you can see it is a really powerful component in Android components toolbox!

In this post I want to highlight several aspects of WebView usage, as long as some of them can cause confusion if you haven't met them before.

1. Display HTML data with special characters (ö, ü, ä, etc.)
It's better to set UTF-8 encoding explicitly, because some Android versions (e.g. 4.0) apparently ignore encoding inside the HTML.

Solution: 
myWebView.loadData(myHtmlString, "text/html; charset=UTF-8", null);

2. Show/hide progress indicator during web page loading
No surprises here, just a tip for a common task! :-)

Solution: set custom WebViewClient with overriden onPageStarted, onPageFinished methods
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
mProgressView.setVisibility(View.VISIBLE);
}

@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mProgressView.setVisibility(View.INVISIBLE);
}
});

3
. Open some URLs with WebView, open other URLs by the default web browser
By default WebView opens all URLs in an external web browser. But if you set custom web client to the WebView (e.g. see 2nd section before), then it will open all URLs within itself. So, you need to override shouldOverrideUrlLoading and implement your custom way to decide how to proceed (open within or external browser).

Solution: set custom WebViewClient and override shouldOverrideUrlLoading
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// open URL in the web view itself
if (url.contains("sample.com"))
return super.shouldOverrideUrlLoading(view, url);
// open URL in an external web browser
else {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
}
});


4. Adjust WebView height when content changes
If you create application like Pocket, Readability or any other HTML content related application - you probably will end up with the need to change WebView content dynamically. It can be loading of the next article, or changing font size to improve users eyes comfort, etc. 
And the tricky part here is that WebView (with layout_height="wrap_content") doesn't shrink down to wrap the new content with smaller height. It grows up correctly (e.g. if you increased font size or loaded an article that is bigger than the previous one). But if you load a tiny article, or set smaller font size - you will see WebView with height as if the previous longer data is still displaying. So there will be white blank space below the content. Why? Seems like a WebView bug. You can google to find that many people complain about it. For example:
http://stackoverflow.com/questions/1973565/how-to-resize-a-android-webview-after-adding-data-in-it
http://stackoverflow.com/questions/10845701/webview-size-is-expanding-but-not-contracting-as-per-the-text-in-it?lq=1

Solution: 
There are lots of suggestions such as: hide and show WebView, check that layout_width was set to "wrap_content", use FrameLayout, and more. And none of them work. So I needed a solution.
The first solution I found is to create a new WebView instance and load required data into it. A fresh WebView instance has a zero height so any data will be taller and all works fine. But, it's quite ineffective to instantiate WebView all the time, also there is a blinking when an theWebView instance is replaced with a new one.
Now I needed a better solution! :-) And I've found it! 
My solution is to load empty data to the WebView, before smaller content can be/should be loaded. And immediately after it proceed to the required action (e.g. load a new article, decrease font size).
// load empty data to shrink the WebView instance
mArticleWebView.loadUrl(Constants.ASSETS_EMPTY);
// load real data
mArticleWebView.loadDataWithBaseURL(null, data, "text/html", "utf-8", null);

Where Constants.ASSETS_EMPTY is just a string constant pointing to the static empty HTML page in the assets folder. So the Constants.ASSETS_EMPTY value could be "file:///android_asset/Empty.html".

With this workaround I am able to implement seamless articles switching and font size changing in my application! :-)


Baca Selengkapnya ....

I am back and with a surpising news!

Posted by Unknown Jumat, 17 Agustus 2012 0 komentar
Hello friends! :-)

As you may noticed there was a short pause for my posts in the blog. And the main reason for this is my wedding. Yeah! :-) I suppose everyone who has married knows very well that wedding is a kind of a really big project! Project is a good word here due to a lot of planning, negotiations, time and money involved.
However, I want to say that we have organized our wedding in the best way we could and it was brilliant!
A lot of our dear guests told us that it was one of the best weddings they ever visited. So warm words for us!

Later we have a fantastic Honey Moon at the Maldives islands. Have you ever heard that the Maldives is one of the most beautiful places on Earth? Well, it's definitely true. ;-)


Well as I already said I am back, so there will be new articles (mostly about Android development) very very soon. Let's stay in touch!


Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android illegal.