Categories
Astronomy

The south pole of the Moon

This photo is one of the first photos taken with the new telescope on October 9, 2020 at 22:21 UT.

Categories
Astronomy

New Astronomy category in this blog

In the last 4 years I have not used this blog but now I want to resume publishing the photos taken with my new telescope.
Astronomy has been a my hobby since I was a child, unfortunately I had to stop for many years and now I would like to start observing the sky again.

On this page you can find my current setup.

Categories
Android

Saving and reading files in the internal storage

You can save and read files in the internal storage as private files which only your app can see except for other apps with root privileges.

Categories
Android

The class LruCache to manage a cache of bitmap objects

The intensive use of many images in an app can create difficulties to the responsiveness and to memory, shown by warnings like ANR (Application Not Responding) or errors like OutOfMemoryError.

Categories
Java

A List with a fixed size

There isn’t a class that extends List for which you can set a limit on its size and that it behaves like a Queue object if you add an item beyond its fixed size.

Categories
Android

Avoiding too frequent updates to the views

In Android in order to avoid to do too work in the main thread, most of the operations should be carried out in a secondary thread or a class that extends AsyncTask; then the final results are reported in some view to be shown to the user using Activity.runOnUiThread(Runnable) or View.post(Runnable) (see Processes and Threads) or Handler.handleMessage() (see Communicating with the UI Thread).

Categories
Android

Golden Rolly

I published an app in Google Play Store named Golden Rolly, it is a game of the category puzzle and you can find a short video presentation here.

Categories
Android

Resetting the preferences on first launch of an app

If you want to reset or change preferences of an app at the first start here is an example of code you can put in an event as onCreate of the main activity:

Categories
Android

Restoring complex objects at restart of an activity

In an android app an activity is created and then destroyed, for example when the user open another activity or when the user presses the back button, later the user opens again the same activity that is is recreated using the data saved before the earlier destruction of the activity.
The data are saved in an object Bundle in the onSaveInstanceState method and restored in the onRestoreInstanceState method (see Recreating an Activity).
The Bundle class provides several setter and getter methods to save and restore data such as getInt and setInt for the integers and similar methods for other types of primitives, strings and one dimensional array.
In this post I write some examples to save and restore more complex objects such as the following CustomObject:

Categories
Java

Stopping the threads

Starting a thread is very easy in java, after you create it you need to call the method start(), for example:

where MyRunnable is a class implementing the Runnable interface overidden the method run().