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.
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, "someemail@domain.com");
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: https://developer.android.com/guide/components/intents-filters.html
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 (http://www.charlesproxy.com/)
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.
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.
@Override
public void onConfigurationChanged(Configuration _newConfig) {
if (mSurfaceView != null)
mSurfaceView.setConfiguration(_newConfig);
super.onConfigurationChanged(_newConfig);
}
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 ...
package-name.AutoResizeSurfaceView
android:id="@+id/mediaplayer_surfaceview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" /
...
/LinearLayout
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:
http://developer.android.com/guide/topics/media/mediaplayer.html
And a really good example-project can be found in the platforms-examples which are part of the Android SDK.