Free Android app covering all aspects of addiction, including prevention and treatment

Using Threads Tutorial

Forget the grass, get off the Main thread!

Android threads tutorial icon

Have you read the article on Processes and Threads yet?

Always remember the two most important rules when working with threads:

  • Don’t block the Main thread
  • Don’t try and access the UI directly from the worker thread

Speed up your apps response times. Move all processing and I/O operations off the main thread. Do the work in a child thread. Our tutorial will show you how.

The parent's in control

fragments tut part3 icon

We only have one activity in our app. It hosts the fragments.

If you haven't already done so, have a look at :

We’re using the support library so make sure that you import the correct class:

fragment tut part2 icon

We'll build the two fragments in this part of the tutorial.

If you haven't already done so, have a look at :


fragmentsTut part1 icon

Our tutorial app has one activity and two fragments. One fragment contains a list and the other an image.

Running the app on a small device in portrait mode, displays the list fragment. Selecting an item in the list displays the second fragment containing an image.

Flipping the device to landscape displays both fragments side by side.

Running the app on a tablet displays the fragments side by side in both portrait and landscape mode.

 

Notification iconMaster the basics of Android notifications

Notifications inform the user about something. They appear in the Notification area at the top of the screen.

Use SharedPreferences for persistant data

User Preference Settings

SharedPreferences are not the same as the typical user preferences where one, for example selects the preferred default sound, text size, colours, etc. for an app.

Android Studio: How to guide and tutorial will show you how to install and use Android Studio to develop Android apps quickly and efficiently. Using almost 200 images, I will take you on a tour through Android Studio, showing you how to import an existing project or create a new one. I describe all the tools at your disposal in Android Studio, tools that will make coding easy for you.Android Studio eBook cover

Once you are familiar with the Android Studio layout, views and tools, I take you, step-by-step through the process of building a simple Android app. This is where you get to apply everything that you have learnt to actually using Android Studio to build an app.

Finally, I show you how to test and debug the app and once you are ready, I show you how to digitally sign the app and build the APK file ready for distribution.

Android Studio: How to guide and tutorial is ideal for beginner Android developers wanting to start coding using Android Studio or those switching over from Eclipse or similar IDE. It offers a quick and easy way of learning Android Studio.

Although Android Studio: How to guide and tutorial, assumes that you have at least a very basic knowledge of Android (or Java) programming, it includes a tutorial on using Android Studio to build a very basic “Hello World” Android app. So even if you have no Android programming experience, you will find this ebook helpful in learning to use Android Studio.

Please note that it will not teach you Android app development, rather it will teach you to use Android Studio which you can then use as a development platform while learning Android app development. Android Studio will make it easier for you to learn to develop Android applications.

Download a sample chapter of Android Studio: How to guide and tutorial

Get your copy now at Amazon books

Also available at Kobo Books

 

Connect your Android device to your computer and simply copy the diy_quiz.txt file that you created to your device's Download folder.

You can also email the file to yourself by adding it as an attachment to the email message. Then open the email on the device and save the file. It should automatically be saved to the device's Download folder.

Remember that the file must be in the Download folder as the Diy Quiz app will only look for the file in this folder

  1. Open up an OpenOffice spreadsheet.
  2. Enter your questions, one per line. Separate fields with the "pipe" character (|). Do not use the pipe character anywhere else in your file. It is used to separate the fields.
  3. Keep the format -- category|question|correct answer|answer 2|answer 3|answer 4|answer 5 -- The first field is the category (or subject), followed by a question. You then need to supply the correct answer followed by four more possible (but incorrect) answers. Each of these fields are separated by the "pipe"character.
  4. Save the file. Select File > Save As from the main menu. Then from the drop down screen:  enter diy_quiz.txt as the File name: and select Text CSV (.csv)(*.csv) as the Save as type: option. "Un-select" the Automatic file name extension box and select the Edit filter settings box. Press the Savebutton to save the file.
  5. In the next pop-up screen, press the Keep Current Format button.
  6. Then, in the next pop-up window, select Unicode (UTF-8) as the Character set, enter the "pipe" character (|) as the Field delimeter and leave the Text delimeter field blank (delete whatever is in there). Press OK.
  7. That's it. You're done.

You can have as many categories and questions as you like (although you probably won't want more than about 10 categories). The order in which you enter the categories doesn't really matter as long as you stick to the format (as described above) for each row. Remember that the trial version only shows two categories.

Once you've downloaded the text file to your device, it will be converted into a database by the app. If you choose to uninstall the app, it won't affect your text file which will remain in the device's Download folder.

    1. Open up a LibreOffice spreadsheet.
    2. Enter your questions, one per line. Separate fields with the "pipe"character (|). Do not use the pipe character anywhere else in your file. It is used to separate the fields.
    3. Keep the format -- category|question|correct answer|answer 2|answer 3|answer 4|answer 5 -- The first field is th category (or subject), followed by a question. You then need to supply the correct answer followed by four more possible (but incorrect) answer. Each of these fields are separated by the "pipe"character.
    4. Save the file. Select File > Save As from the main menu. Then form the drop down window:enter diy_quiz.txt as the File name: and select Text CSV (.csv) (*.csv) as the Save as type: option. Clear the Automatic file name extension box and tick the Edit filter settings box. Click the Savebutton.
    5. In the next pop-up screen, select the Use Text CSV Format button.
    6. Then, in the next pop-up window, select Unicode (UTF-8) as the Character set, enter the "pipe"character (|) as the Field delimiter and clear the Text delimeter field. Press OK.

That's it! You're done.

You can have as many categories and questions as you like (although you probably won't want more than about 10 categories). The order in which you enter the categories doesn't really matter as long as you stick to the format (as described above) for each row. Remember that the trial version only shows two categories.

Once you've downloaded the text file to your device, it will be converted into a database by the app. If you choose to uninstall the app, it won't affect your text file which will remain in the device's Download folder.