Testing with MonkeyRunner

We used an automatic Gui Testing tool for android apps. We had a emulator for an tablet running on an laptop and tried to test our app. The problem was that the runs were sometimes successful and sometimes not with the same code.

I used Retrofit for the REST part. Retrofit allows to perform a REST-call asynchronously. Do develop the one-at-a-time synchronization approach for the tables I packed every asynchronous call into an Executor Service, which supports the detection of finished threads. As a result I could detect for every local table if the synchronization succeeded.

Android - synchronize all

I have to implement a “synchronize”-button in an Android app such that when pressing the button the local data is synchronized with a server. I (a beginner in this field) have to access a REST-Interface to send new data, which was generated on the app and request new data to update the local database with data from the server. The app should monitor for each database table - synchronization if something went wrong (esp. when sending data to the server-db) and immediately stop if so. The problem is that Android does not allow sending data over the network on the UI-thread so i can't just simply implement a loop there.

Use putExtra(...) function to pass values between Android activities

Intent class function putExtra(String name, char[] value) is able to add extended data to the intent. The first parameter (name) must include a package prefix. For example if we wanted to create a new email activity and pass the value some email address we would do the following (assume we call from activity class):
Intent email = new Intent(getActivity(), EmailActivity.class);
email.putExtra(MainActivity.CURRENT_EMAIL, "");

where as MainActivity.CURRENT_EMAIL acts as a key in this case. Its value must contain package name, for example: "com.example.EMAIL". Further reading in documentation under section Extras:


Can't connect Nexus 4 to ADB (Android Debug Bridge): unauthorized

I want to connect my Nexus 4 to adb and make it authorized.

Create android application by using standard web technologies such as HTML5, CSS3, and JavaScript

The goal is to build applications for mobile devices using well known standard web technologies like JavaScript, HTML5, and CSS3, instead of device-specific languages such as Java or Objective-C.

Some starteri-help for android?

I would like to learn coding on Android, but Android is difficult and scary. Developing for Android is often described as a cumbersome task - I know Java, but Android is apparently a little more difficult than "mere" Java complexity.

How to see all of the HTTP and SSL / HTTPS traffic of your Android smartphone

There are two ways to see the traffic of your phone.

The first one can only be used for Android versions 4.0 and higher.
First install a proxy application as Charles (
Then take your phone and navigate to the WIFI-Settings (settings->wi-fi). Make a long click on the connected network and select the "modify network" option. If you check the "show advanced options" you can scroll down a bit and see settings for proxy. Select the "manual" option and write the ip-address as proxy hostname and the port. If you are running Charles you can find the ip-address when navigating to Help->Local-Ip-Address.. The port for Charles is always 8888.
Save the settings and you are done. Now you see the whole traffic in the Charles-Session-Window. If you don't need the proxy anymore don't forget to remove it from the settings on your phone.

The second way is working for all Android versions.
First install a tool like Wireshark or Charles and use the proxy for your computer. Then use ethernet-connection and share the internet over wifi from your computer. Take your smartphone and select your shared wifi as the network.
And now you're done. You can see the whole traffic in your proxy-tool. The only disadvantages of this way are that you need an ethernet-connection and you see the traffic of your computer also.


How to implement autoresize/autorotate of Android Player?

To be able to change the View of the player depending on the rotation of the device we have to use the MediaPlayer-Class instead of the VideoView-Class.

So first you have to extend the SurfaceView and to catch the event when the size of the view is calculating. This event is called "OnMeasure" (From Android Documentary: OnMeasure - Called to determine the size requirements for this view and all of its children). So every time the view was changed and has to be drawn again or when the device rotates, this event will be called. This is the moment where we have to calculate the size of our surfaceView. Therefore we need to know the orientation of the device.

To be able to handle the orientation-changed-event we have to set a flag in the AndroidManifest class.
So for the activity, which will contain the mediaplayer, we have to set android:configChanges="screenSize|orientation". Now we can handle this event without a restart of our activity and pass the new orientation to our surfaceview.

public void onConfigurationChanged(Configuration _newConfig) {
if (mSurfaceView != null)

Now our surfaceview is able to change the size depending on the orientation. To add it to our activity-layout we can add it to the xml as followed:

LinearLayout ...
android:layout_gravity="center" /

So actually that's it. A possible implementation of the custom surfaceview is attached to this solution. The final step is to implement the mediaplayer, which uses our custom surfaceview.

The implementation of the mediaplayer is documented here:

And a really good example-project can be found in the platforms-examples which are part of the Android SDK.


Transfer contacts from Nokia Phone (Symbian) to Google Phone (Android)

In the company I worked, I used Windows, Outllok and Nokia Phone N97mini. During that time I managed all my contacts at my company phone, which was used as private phone too. There is the standard tool from Nokia to synchronize contacts between Windows Outlook and the phone, called "PC Suite". In fact with PC suite there is much more possible, e.g. writing SMS messages on the PC (which is much more convinient). Unfortunately there is no such tool for the Android driven Google phone, so one cannot easily transfer the contacts stored in outlook to Android. Additionally my private computer runs with Linux, while the company computer is Windows driven. I want to transfer the contacts from my Nokia Phone to the Android-phone (Google Nexus).


Subscribe to android