Showing posts with label mobile. Show all posts
Showing posts with label mobile. Show all posts

Wednesday, April 18, 2018

Create a Fragment App with Android Studio 3.1

This is a follow up from my previous Android Fragments in an Activity.

This example, demonstrates how Fragments are created and loaded by an Activity class. Android Studio 3.1.1 is the IDE with Java 1.8.0 and an emulator is created with API 23. All this is running on Centos 7.

Step 1: Create an Empty project with vertical orientation

Open Android Studio and create a new project.
Application name: My Fragment
Click Next

Click Checked for Phone and Tablet
Minimum SDK: choose API 23:Android 6.0 (Marshmallow)
Click Next

Choose "Basic Activity"
Click Next

Activity Name: MainActivity
Layout Name: activity_main
Title: MainActivity

Click checked Use a Fragment

Click "Finish"

This will provide a template to quickly create the rest of Fragments to be used with this Activity.

A total of 23 files are created in the app/src/main folder. By the time all steps are completed, there should be 29 files created in app/src/main folder.
=== Listing of 25 files at start of the project===
app/src/main/res/drawable/ic_launcher_background.xml
app/src/main/res/values/colors.xml
app/src/main/res/values/strings.xml
app/src/main/res/values/dimens.xml
app/src/main/res/values/styles.xml
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
app/src/main/res/drawable-v24/ic_launcher_foreground.xml
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
app/src/main/res/mipmap-hdpi/ic_launcher.png
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
app/src/main/res/mipmap-mdpi/ic_launcher.png
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
app/src/main/res/mipmap-xhdpi/ic_launcher.png
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
app/src/main/res/layout/content_main.xml
app/src/main/res/layout/activity_main.xml
app/src/main/res/menu/menu_main.xml
app/src/main/java/com/example/nicholas/myfragment/MainActivity.java
app/src/main/AndroidManifest.xml
===
Project Structure of application - Newly create project




A default project contains the following layouts
activity_main.xml
  • CoordinatorLayout
    • AppBarLayout
    • Toolbar
    • an include layout tag
    • FloatingActionButton
content_main.xml
  • ConstraintLayout 
  • TextView.
Edit the layout/activity_main.xml
In the CoordinatorLayout tag, insert following line before tools:context

tools:orientation="vertical"

Step 2: Add the buttons

Edit the file values/strings.xml and add within the <resources> tag

<string name="digital">Digital</string>
<string name="analog">Analog</string>

<string name="textclock">Text Clock</string>

Edit content_main.xml and remove the whole TextView tag. Replace with 2 buttons where you can just drag and drop the buttons from the widget list. Add a FrameLayout where we will position our Fragment layouts. Edit the button code as follows

<Button
        android:id="@+id/button_analog"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/analog"
        />
<Button
        android:id="@+id/button_digital"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:text="@string/digital"
        app:layout_constraintTop_toBottomOf="@+id/button_analog"
        />

<Button
        android:id="@+id/button_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:text="@string/textclock"
        app:layout_constraintTop_toBottomOf="@+id/button_digital"
        />

<FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="280dp"
        android:layout_height="495dp"
        android:layout_marginStart="8dp"
        app:layout_constraintStart_toEndOf="@+id/button_analog"
>
    </FrameLayout>


Let build and run the project.

Click the Run App button (green play button) or press Shift+F10. I am using an API 23 emulator for my test applications. Create the Android emulator if it is not done yet.




Step 3: Create Analog Fragment

Click File ->New ->Fragment ->Fragment (Blank). Fill following values
Fragment Name: AnalogFragment
Fragment Layout Name: fragment_analog

Leave all other options checked.
Click Finish

In AnalogFragment.java, replace import android.support.v4.app.Fragment with

import android.app.Fragment;

I plan to provide support only to Android API 23 and above.

Lets explore the Design editor.
Edit layout/fragment_analog.xml and click the tab Design. Notice that the default is FrameLayout.



On the left is the Palette, in the middle is the screen design + blueprint, on the right is the Attributes list. In the Design area, click the menu to choose API 23. Right click any where on the design and choose Convert FrameLayout to ConstraintLayout. Click "Ok".

Delete the default TextView in the design.


From the Palette, notice there is no AnalogClock which means it will have to be manually added. Click the Text tab and insert the following

<AnalogClock
        android:id="@+id/analogClock"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"

        app:layout_constraintTop_toTopOf="parent"
         />


Step 4: Connect MainActivity with Analog Fragment

I have broken down the steps further in this step. Edit MainActivity class.

1. Add following member variables

Button analogButton;

2. Edit protected void onCreate(Bundle savedInstanceState), add after the line setSupportActionBar(toolbar)

analogButton = (Button) findViewById(R.id.button_analog);
analogButton.setOnClickListener(this);


There should be a wriggly red line at the text "this", click once then press Alt+Enter. Choose "Make MainActivityFragment implement android,view.View.OnClickListener". Choose "onClick(v:View):void" and press "OK".

3. Add onClick(View v) method
FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
if(v==analogButton){
        f = new AnalogFragment();
}
transaction.replace(R.id.fragment_container, f);

transaction.commit();

4. Edit the class declaration with the AnalogFragment

public class MainActivity extends AppCompatActivity implements View.OnClickListener,
        AnalogFragment.OnFragmentInteractionListener  {


Implement AnalogFragment's OnFragmentInteractionListener, add the method near the end of the class.

public void onFragmentInteraction(Uri uri) {
        //
}



Compile and run.

Step 5: Create Digital Fragment

Repeat steps 3 and 4 above but change the Analog to Digital. Below is the code to display a digital clock

<DigitalClock
    android:id="@+id/analogClock"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:background="#9a0"
    android:padding="24dp"
    android:textColor="#eff"
    android:textSize="25sp"
    android:textStyle="bold"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"

    app:layout_constraintTop_toTopOf="parent"
    />




Step 6: Create TextClock Fragment

Repeat steps 3 and 4 above but change the Analog to TextClock. Below is the code to display a digital clock

<TextClock
    android:id="@+id/analogClock"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:background="#9a0"
    android:padding="24dp"
    android:textColor="#eff"
    android:textSize="25sp"
    android:textStyle="bold"
    android:format12Hour="HH:MM:ss EEEE"
    android:format24Hour="EE H:mm:ss"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"

    app:layout_constraintTop_toTopOf="parent" 
    />


Here is the complete source code for MainActvity.java

1:  package com.example.nicholas.myfragment;  
2:  import android.app.Fragment;  
3:  import android.app.FragmentManager;  
4:  import android.app.FragmentTransaction;  
5:  import android.net.Uri;  
6:  import android.os.Bundle;  
7:  import android.support.design.widget.FloatingActionButton;  
8:  import android.support.design.widget.Snackbar;  
9:  import android.support.v7.app.AppCompatActivity;  
10:  import android.support.v7.widget.Toolbar;  
11:  import android.view.View;  
12:  import android.view.Menu;  
13:  import android.view.MenuItem;  
14:  import android.widget.Button;  
15:  public class MainActivity extends AppCompatActivity implements View.OnClickListener,  
16:      AnalogFragment.OnFragmentInteractionListener, DigitalFragment.OnFragmentInteractionListener,  
17:      TextClockFragment.OnFragmentInteractionListener {  
18:    Button analogButton, digitalButton, textClockButton;  
19:    Fragment f;  
20:    @Override  
21:    protected void onCreate(Bundle savedInstanceState) {  
22:      super.onCreate(savedInstanceState);  
23:      setContentView(R.layout.activity_main);  
24:      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);  
25:      setSupportActionBar(toolbar);  
26:      analogButton = (Button) findViewById(R.id.button_analog);  
27:      analogButton.setOnClickListener(this);  
28:      digitalButton = (Button) findViewById(R.id.button_digital);  
29:      digitalButton.setOnClickListener(this);  
30:      textClockButton = (Button) findViewById(R.id.button_textclock);  
31:      textClockButton.setOnClickListener(this);  
32:      FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);  
33:      fab.setOnClickListener(new View.OnClickListener() {  
34:        @Override  
35:        public void onClick(View view) {  
36:          Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)  
37:              .setAction("Action", null).show();  
38:        }  
39:      });  
40:    }  
41:    @Override  
42:    public boolean onCreateOptionsMenu(Menu menu) {  
43:      // Inflate the menu; this adds items to the action bar if it is present.  
44:      getMenuInflater().inflate(R.menu.menu_main, menu);  
45:      return true;  
46:    }  
47:    @Override  
48:    public boolean onOptionsItemSelected(MenuItem item) {  
49:      // Handle action bar item clicks here. The action bar will  
50:      // automatically handle clicks on the Home/Up button, so long  
51:      // as you specify a parent activity in AndroidManifest.xml.  
52:      int id = item.getItemId();  
53:      //noinspection SimplifiableIfStatement  
54:      if (id == R.id.action_settings) {  
55:        return true;  
56:      }  
57:      return super.onOptionsItemSelected(item);  
58:    }  
59:    @Override  
60:    public void onClick(View v) {  
61:      FragmentManager manager = getFragmentManager();  
62:      FragmentTransaction transaction = manager.beginTransaction();  
63:      if(v==analogButton){  
64:        f = new AnalogFragment();  
65:      } else if (v==digitalButton){  
66:        f = new DigitalFragment();  
67:      } else if (v==textClockButton) {  
68:        f = new TextClockFragment();  
69:      }  
70:      transaction.replace(R.id.fragment_container, f);  
71:      transaction.commit();  
72:    }  
73:    @Override  
74:    public void onFragmentInteraction(Uri uri) {  
75:      //  
76:    }  
77:  }  

Done.

Tuesday, April 17, 2018

Upgrade Android Studio to 3.1

New in Android Studio v3.1.1 on Stable channel are
  • For those who use C++, there is a CPU performance profiler that troubleshoot codes with the  simpleperf tool. 
  • Better lint support to check quality of codes for Kotlin (an alternative JAVA language). From the command line, lint can be accessed with the tool gradlew lint.
  • Improved  SQLite's and Room's table query and creation.
  • The default compiler uses D8 dexer which have the capability to make codes much smaller and more accurate step debugging.
  • Improved build output window to trace errors in a tree view.
  • Upgrade to the IntelliJ Idea 3.3 platform. This is the base platform of which Android Studio IDE is built.
  • Improved network profiler to trace network request on multi-threaded traffic.
The new version patch size is 456MB. Can hardly spot any difference from previous versions but its running much more smoother.

Android Studio 3.1.1 Workspace


Here is the current PC setup
  • Android Studio version: 3.0.1 (build 171.4443003) 
  • Centos 7.4 (64 bits) Linux 3.10.0 x86_64 amd64
  • OpenJDK 64-bit v1.8.0_161
  • Gradle 4.3.1
  • Apache Ant 1.9.6

This is how I upgraded to Android Studio 3.1.1

Check for updates


Canary or Stable channels can be check with the following steps.
Open Android Studio menu and click File ->Settings ->Preferences. On left panel choose Appearance & Behavoir ->System Setting ->Updates. Choose the Stable Channel from Automatically check updates for.

Click Check Now. This should retrieve latest update on the Stable Channel.

Step 1: Update Android Studio

Choose to update from the popup window when Android Studio is open.


Do the steps above if you have not retrieved the updates information. Click Update and Restart.


Alternatively, at the bottom of the Android Studio start page, click "Check" if you do not find the update option.

Once update starts, this will begin with download of the required files.

Step 2: Configuration

After it has installed the update, choose to import my settings from a previous version (keep existing configuration) from the window Import Studio Settings from: choose the option below and click "Ok"

Previous version (~/.AndroidStudio3.0/config)

Step 3: Update Plugin and other components

Close all emulators then open an existing project. This will have the usual build checks, once the gradle has started processing, the following window will appear.


Click Update to update Android Gradle Plugin to version 3.1.1 and Gradle to version 4.4. Wait until the Gradle project sync in progress... is completed.

At the window IDE and Plugin Updates, click "update". To update currently installed SDK and it tools, click "Update now".


Once completed download, click Finish. In my case it took 1.5GB of downloads.


Next up: Will write on creating a Fragment type application with Android Studio 3.1.
Done.

Wednesday, February 14, 2018

Cordova: Accepting user input

What would be the first thing in programming? A simple use of variable and user text input comes to mind. Following the previous post (link here), the Cordova programming environment is set up for Android. The existing files will be edited to do the following;

The HelloWorldApp when started, will prompt the user to enter a city name.






The user enters a city name and press "OK" button. The city name will be displayed on the app.






Step 1. Position the text to display user response.

Using a text editor, open the file index.html in HelloWorld/www and replace the previous <p> tag with the text "Hello World" with;

<div id="answer"></div>

Save the file.

Step 2. Prompt user at apps startup and display the reply.

Open the file index.js in HelloWorld/www/js

Add our function called getAnswer to the end of the file;
function getAnswer() {
    var ans = prompt("Name your city");
    if (ans.length > 0) {      
        document.getElementById('answer').innerHTML = "";      
        document.getElementById('answer').innerHTML = ans + " is a great place.";
    } else {      
        getAnswer();
    }
}


Activate the getAnswer function in the initialize:function( )by adding after document.addEventListener(...);

getAnswer( );

Step 3. Build and launch the app.

At the command line interface (CLI) or the command terminal, type

$ cordova build android
$ cordova run android

This will launch the default emulator.

In order to test the app, at any time after editing to the source files, just follow this Step 3.

Troubleshooting

Android emulator error: 
The connection to the server was unsuccessful. (file:///android_assets/www/index.html)

Edit the file config.xml in HelloWorld folder. Add the following line after the </platform> tag.

<preference name="loadUrlTimeoutValue" value="700000" />

Build and launch the app.

Tuesday, February 13, 2018

How to Install Cordova for Android Development

One challenge in developing a mobile application is in choosing a mobile environment. Apache Cordova allows building of an application through the use of Java for Android, AngularJS, SCSS to create reusable code across platforms. I suggest that some study is done on those languages in order to fast track learning. Cordova supports several development platforms, for this article, its focus is on Android platform.

Cordova Installation

Here are the steps to get started on a command line with installation of Cordova and launching the Android emulator on MS Windows 10 (version 10.0.16299). All the versions mentioned here are those that I am using for this article.

1.Install Base Environment

Cordova relies on well known development tools to generate the latest mobile application. Install Java Development Kit (version 8 or newer), Android studio, Node.js and git. Ensure all these are working.
  1. Java Development Kit. This should be version 8 or newer and configure JAVA_HOME.
  2. Android Studio (This article is version 2.3.3). Install the required SDK platform (I choose Android 7.1.1 Nougat), SDK Tools comprising of Android SDK Tools (version 26.1.1), Android SDK Platform-tools (version 27.0.1) and Android Support Repository (version 47.0.0). In SDK Tools, install Android Emulator. On MS Windows platform, also install HAXM (I have version 6.2.1).
  3. Node.js. This article is version 6.9.1 with npm 3.10.8. 
  4. Optional: GIT (version 2.8.1.windows.1)
Ensure environment variables are configured for JAVA_HOME and ANDROID_HOME

Then at the command prompt type (do not type the dollar sign);
$ npm install -g cordova

On linux
$ sudo npm install -g cordova

2. Creating Hello World App.

We will create a Cordova project in a folder HelloWorld. This will be in io.cordova.project with the app title of HelloWorldApp.
$ cordova create HelloWorld io.cordova.project HelloWorldApp
$ cd HelloWorld

Here is the syntax to create any project
cordova create [project_name] [package_name] [apk_name]

Open the folder platforms, notice it is empty.
Cordova Project folder for HelloWorld


Open and identify the codes in index.html located at
HelloWorld\www


In HelloWorld\www edit index.html to display Hello World. At end of the app tag, add 1 line
<div class="app">


<p>Hello World</p>
</div>

3. Install Android Platform.

When it is the first time creating a project, the target platform has to be added. Here its created in a folder CordovaProject.
$ cordova platform add android

Have a look at the Android source files are located at MainActivity.java in

HelloWorld\platforms\android\app\src\main\java\io\cordova\project

Default MainActivity.java file

Each time the apps code is modified, the project is compiled and run in an emulator OR on a mobile device. Compile and build the project for the Android platform.
$ cordova build android

Start the apps in an emulator. The default emulator manager is by Genymotion and the default emulator is Pixel with Android API 25.
$ cordova emulate android.


If you intend to plug in your Android device to run the app, or  start the apps in an external device, type
$ cordova run android



4. Tips

List existing platform installed and what platform is available.
$ cordova platform ls

Friday, January 13, 2017

Howto reinstall Samsung Galaxy S5

The Samsung Galaxy S5 is a powerful phone and have lasted me over 2 years. Regular updates and the many different applications installed and removed does cause the storage to be bloated and its good option to clear everything and reinstall only the required apps after such a long time.

I will be doing a factory reset (wipe out all data on phone) then allowing the Galaxy S5 to restore last saved settings and finally restore application settings from Samsung Smart Switch (the PC software provided by Samsung). A USB cable is required to connect Galaxy S5 with the PC running the Smart Switch. Make sure the phone is detected when using the USB cable, else you may need to get another USB cable.

IMPORTANT
Backup all your data before proceeding. Copy your login information for Google, Samsung and other apps on a paper, if you need to.

Before we begin, there are 2 steps to be carried out;

BACKUP PHONE INFORMATION
Use the Backup and Restore.
From the phone, select the Settings (This usually looks like a gear when you pull down to display the menu from top of the screen) and choose Backup and Restore. Choose your backup and restore settings, including storing it on Google drive.

Backup other settings and apps to a PC or external storage as needed.

SAMSUNG SMART SWITCH
We will be using Samsung Switch, so go ahead and install this on a PC.  Start Smart Switch, plugin the Galaxy S5 phone to the PC via USB cable, then do backup of applications and other media that you require.

Here are steps taken to reinstall the smart phone from Samsung. Make sure the phone is fully charged BEFORE you start.

Step 1. FACTORY RESET (optional)
From the phone, select the Settings (This usually looks like a gear when you pull down to display the menu from top of the screen) and choose Backup and Restore. Then choose Factory Reset.

This may take a while as it will also reinstall default applications found on the phone.

Step 2. INITIALISE THE PHONE
Start the phone and follow the instructions to setup. I choose not restore all Apps from google but only the settings. Finish the setup with last steps that include confirmation of the phone name.

Step 3. UPDATE AND RESTORE DATA
On the PC, start Smart Switch then plugin via USB the Galaxy S5 phone. If prompted to upgrade, accept and follow instructions provided. Strongly suggest that the CAUTION message displayed is followed to avoid wasted time on failed software update.

Smart Switch update software for Galaxy S5

Smart Switch CAUTION messages

You will need to disconnect the cable once its done. This will cause the phone to restart, wait a little bit as it flashes the text "SAMSUNG", then it will show "Android is upgrading" before the phone can resume as normal. For me, on the phone it mentioned optimizing app total of 284, and this restart process took just over 15minutes before I could get the login screen.

RESTORE DATA
Start Smart Switch on the PC. Login to the phone and plug it to the PC using the USB cable.

Smart Switch should detect the phone, then clik on the Restore button and follow the instructions. Once restore is complete, disconnect he USB cable. On the phone, Check the Contact, calendar and other contents that is needed.

TIPS
Find Lock a lost Samsung phone using a web browser.
Open a web browser and type location as https://findmymobile.samsung.com and login with the Samsung account used with the phone. Here is a well documented site on ensuring that you enable basic actions that you can take when the phone is lost.

Thursday, August 11, 2016

Pokemon Go the Start of The Unity

Recently Pokemon Go, a location based game have taken the game industry by storm. Literally more people are getting up and going around in search of Pokemons, Poke stops, Gyms and other parts of the games. This is a little off open source topic, but its a rather attractive game using location base and augment reality.

Niantic Labs was founded by Google before it separate to a separate company known as Niantic. Pokemon Go is a successful product of Niantic as indicated by the number of installations.

Looking at the permission that must be allowed for the game to run, its literally having a access to a wide range of information. Millions of users are allowing access to Niantics.

Could this be used for big data? possibly the first signs of Unity, as in the Matrix?


Graphics on the different type of Pokemon in case you need to take on Unity in the future. How many of each type do you have? and whats the strongest?
  • Bug
  • Dark
  • Dragon
  • Electric
  • Fairy
  • Fighting
  • Flying
  • Normal
  • Poison
  • Psychic 
  • Water

Tuesday, September 29, 2015

Tutorial on Multiple Fragments in Activity

Here is an example to describe in codes how to create Fragment classes with Android Studio 1.4.

I wanted to be able to receive Button events and switch the Fragment depending on user selection. Need to be careful with rendering the layouts lower than API 23, as it did not generate the Design view properly.

Android Fragments in an Activity



Friday, September 25, 2015

Notes on the Sunshine app

Reviewed back lessons over last few months.

"Notes on Udacity Developing Android Apps"

Biggest problem was not passing the correct object to the ViewList. It kept giving a null error upon running the application.

The logging system was truly helpful for errors at runtime.


Upgrade to Android Studio 1.4 RC2

That was fast, RC1 was out in early September 2015 and shortly after that RC2 is released on 23 September. View the upgrade installation for Canary channel, RC1 at "Upgrade to Android Studio 1.4 RC1". Upgrade was smooth and without any problem recompiling target API 21 apk.

RC2 provide bug fixes and includes;

  • Update to the Theme Editor (using style.xml files)
  • In performance monitors it includes GPU and network profiler
  • The Vector Asset Wizard creates Android XML vector drawables, icons, from SVG files
  • Improved Android permission checks 
It is stable in terms of use and will surely provide a good experience for first time Android developers. With Android Studio 1.4, education institutions will surely be able to introduce Android Programming to a more advanced level, similar to how C++ was widely used.

Here are steps to upgrade RC2 from RC1;

Step 1: Check for updates

Start Android Studio and in the menu choose Help-> Check for Updates...
Click "Update and Restart". Ensure you have administrator rights to update the application or accept the request to update if such a request window appears.


Step 2: Restart Android Studio

This would be automatic if all went well. Verify RC2 is installed in the About.


Done.






Sunday, September 20, 2015

Samsung S5 Wifi not connecting automatically

Samsung S5 is a powerful Android mobile phone. In May 2015, the S5 received an update to Android 5.0 but has since had a problem with the wifi.


The smart network switch automatically switches from wifi when it gets weak, to mobile data. Usually, to save on mobile data its a good idea to turn it off. This way, even if wifi is weak it still stays on until signal is lost.

It can connect to wifi. However even after choosing smart wifi, it does not automatically reconnect when returning to the most wifi access point (AP) that it has saved the password. I say most because it can connect to open public wifi like Starbucks.

Previously, before the upgrade it was able to connect without problem.

Even resetting to factory did not help. Probably had something to do with me restoring my backup.

Here is how I got it working, clearing the S5 phone cache.

Step 1: Power off the S5

Step 2: At same time hold down following keys;
Volume up, power on/off, Home.

When it vibrates or see the galaxy start screen, release the power on/off.

Step 3: clear cache and restart
Use the volume key to select clear cache. Press the power button.

Once it says cache cleared, use volume button to select restart of phone and press power button.

Done.

Monday, February 2, 2015

Howto Update to Android Studio 1.1

The Android Studio 1.1 Preview 2 is released to address bug fixes. Many new Android developers will benefit lots from the bug fixes and will have better experience on Android development with this powerful IDE.

Look for details on the update at android.com. One nice feature is having the AVD Manager on a separate window. This is great for multi display set ups.






Monday, December 22, 2014

Debug Android App in Android Studio

In MS Windows, Android Studio provides debugging options in its IDE.

For some who prefer to use the command line, there is the command adb to call debugging. Example

adb logcat

But if you get an error that is similar to;

'adb' is not recognized as an internal or external command, operable program or batch file.

Then, the adb path must be made known. Here are notes for MS Windows 8, with Android Studio version 1.0.1

Step 1: Copy the path for the Android Platform-Tools.

This is by default 
C:\Users\[YOUR USERNAME]\AppData\Local\Android\sdk\platform-tools

Replace [YOUR USERNAME] with the username in use by your system. This means that the computer lab should have done this, otherwise "Administration" rights is needed.

Step 2: Edit the MS Windows, System Environment's Path variable

Open the Windows Environment Variables in System Properties. Add (or Edit) to the end of Path variable in "System variables" with the value in step 1 above. Close all the boxes and restart the MS Windows all "cmd" terminal.

Step 3: Test

Unplug the Android device OR turnoff the emulator. In the Android Studio's command prompt OR in MS Windows cmd prompt type 2 commands to test;

> adb version 
Android Debug Bridge version 1.0.32
> adb logcat
- waiting for device -

Quick Guide to Using ADB 

Following are basic commands to use the debugger from a terminal. Firstly, plugin a device (or start up an Android emulator). The ">" below is a prompt to enter commands from the command line.

List available emulator or devices
> adb devices
List of devices attached
4df7a2af25be30c1        device

In the above example, "4df7a2af25be30c1" is the attached mobile Android device.

Access the emulator or device shell
> adb shell
or a specific device
> adb -s 4df7a2af25be30c1 shell

From here, you can issue commands within the device. Press Ctrl - D to exit.
One commonly used command is logcat to display logging info of the application. Code learn provides some basic tips.

Display memory usage by application
> adb -s 4df7a2af25be30c1 shell dumpsys meminfo

or by a specific application

> adb -s 4df7a2af25be30c1 shell dumpsys meminfo  com.example.tboxmy.helloworld

Tuesday, August 26, 2014

Quick start to Mozilla Firefox OS 1.x

For those of you who were looking for a new smart phone, it might be good to also look at Firefox OS. This is being developed by Mozilla and will be a game changer.

Quick notes:

  1. Initially known as B2G (Boot to Gecko) in the Mozilla Project and initially demonstrated in 2012
  2. Has a Linux based operating system
  3. Target for smart phones, tablets and smart TV.
  4. Among the first adopter was ZTE Open phone
  5. Its has 4 software layers. I.e. Gonk (Linux kernel), Gecko (application services), XUL Runner (Application run-time) and Gaia (User interface system)
  6. Supports HTML5
  7. Website at https://developer.mozilla.org/en-US/Firefox_OS
  8. Apps can be found at the Firefox marketplace.
Current development is at Firefox OS 1.3 (Stable) and Firefox OS 2.1 (Unstable)  and you can try it out via a simulator.

Following are steps to install and run a simulator:
Requirements: Firefox version 30+

Step 1. Install the simulator.

Open Mozilla Firefox web browser and access "App Manager add-ons" by typing in the URL
https://ftp.mozilla.org/pub/mozilla.org/labs/fxos-simulator/

Click "Install Firefox OS 1.3 Simulator (Stable)" or which ever version pleases you.

When the Pop-up appears, Click "Allow" then wait till the download starts (There isn't any indicator onscreen) and when the Software Installation box appears, click "Install Now".

Click "Firefox OS 1.3 Simulator has been installed successfully."

Step 2:  Check installation

To determine if its installed, open Mozilla Firefox web browser and enter URL as
about:addon

You should see "Firefox OS 1.3 Simulator ...."

Step 3: Start up the App Manager

In Mozilla Firefox web browser enter URL as
about:app-manager

At bottom of the  App Manager click "Start Simulator"
The Firefox OS Simulator will appear as a new Firefox Window.


Congratulations...you now have access to the latest Smartphone OS.





Tuesday, July 8, 2014

Howto Turn On Menu and Back Button Lights on Samsung S3

The Samsung S3 is a clever device to conserve energy, but to some users who keep forgetting where is the frequently invisible "Menu" and "Back" buttons, they should have it lit all the time (and off when screen is off).

These buttons are on the left (Menu) and right (Back) of the Home button. By default, each time either keys are pressed, the lights will stay lit for about 1.5 seconds only.


Here are step to have "Menu" and "Back" buttons lit all the time (and off when screen is off).

Step 1. At the Home screen, go to settings.
Simple? For the unacquainted, just touch the Apps button (usually the centre circle at bottom of the screen) and choose settings.

Step 2. Choose "My device", scroll down and touch "Display". 

Step 3. Scroll down to touch "Touch key light duration".

 Step 4. Choose "Always on".

Press "Home" and you will notice the lights are lit next to the "Home" key. If the screen if off, these lights will also go off.

Howto Turn Off Samsung S3 keyboard sound

For some reason, the keyboard on Samsung S3 (GT-I9300) started to beep with each press and this gets annoying after having to type lots. Instructions can be applied for most Android 4, but here the screenshot are for Android 4.3 kernel version 3.0.31-2429075 dpi@HP20 #1.

To turn off/on the sound in 3 simple steps;

Step 1. At the Home screen, go to settings.
Simple? For the unacquainted, just touch the Apps button (usually the centre circle at bottom of the screen) and choose settings.

Step 2. Choose "My device", scroll down and touch "Language and input"





Step 3. Scroll down and find Key-tap feedback "Sound". To turn keyboard sounds off, uncheck the "Sound" box.


Press the "Home" key and you can test out keyboard sound, off or on as you have  selected.


Monday, November 18, 2013

Backup Samsung S3 with KIES

Time to send the Samsung Galaxy S3 to the workshop as its difficult to charge despite changing several chargers. Problem: Need to wriggle the USB connection to charge.

Attempting to use KIES from Samsung.

A) Install KIES

Step 1. Download and install from http://www.samsung.com/my/support/model/GT-I9300RWDXME-downloads?downloadName=SW

Step 2. Update the KIES for PC (Final part of the installation above for 18 Nov 2013, version 2.6.1.13105_6_1 (See diagram below)


B) Run Backup
Step 1. Start Samsung KIES (not the LITE)

Step 2. Click the tab "Back up/Restore". Yes, they put a space between Back and up.


Step 3. Click "Select all items".

Step 4. Select which directory to store the backup. Click "Tools" ->Preferences ->Browse

Step 5. Click "Backup". Now they decided there is NO space between in this word.






Monday, September 2, 2013

Maxis site not supporting Mozilla or Chrome

A sudden change in policy at Maxis, one of the main telco in Malaysia or is it just my network problem?

Either way, last Aug 2013, Maxis customer support just informed me to use Internet Explorer (IE) or they can help email my bills. They tried, but the bill never arrived.

Now in September, I still can't login to get my bills using Chrome or Firefox. But wait, I see an additional notice at their portal....interesting. I added a text bubble.



I guess they are expecting me to call them for help on my bills.

2 Sept. Just spoke to customer service. Seems their Firefox is able to login and the Firefox version 23.0.1 that I am using not current enough. Huh? Is there a newer version since as of today?

On Firefox version 23.0.1, have disabled pop-up blocker, block reported attack sites/web forgeries, nothing happens when I click the "login" button. Ran IE (finally) and the login button works. Still not working on Google Chrome and Firefox.

Anyone else with this problem?

Wednesday, August 14, 2013

Using Handlerbars and JQuery in PhoneGap

Here is the very basic steps to use a template model in a PhoneGap application. I won't be going in details in this note.
"Those attending the PhoneGap class should incorporate the database as a practice. Thank you"

Ensure that the following steps have already been taken
  1. Creating Android App with PhoneGap
  2. Using Alert Pop-up
Step 1: Install the Handlebars and JQuery scripts
Download
  1. Handlerbars from http://handlebarsjs.com
  2. JQuery 1 from http://jquery.com/download/
Extract and copy the .js files to the Project's assets/www/lib folder

Step 2: Update the index.html
Replace the the contents within the body tags with the following;

 <h1>Hello PhoneGap</h1>  
  <script id="a-comment" type="text/x-handlebars-template">  
   <p><b>{{name}}</b> on {{date}}</p>  
   <ul>  
   {{#each comment}}  
   <li>{{description}}  
   {{/each}}  
   </ul>  
 </script>  
 <script src="lib/handlebars.js"></script>  
 <script src="lib/jquery-1.10.2.min.js"></script>  
 <script src="js/main.js"></script>  

Step 3: Update the js/main.js
Remove the initialize: function() and add following codes;


      renderHomeView: function() {  
      var today = new Date();  
      var dateTxt = today.getDate() +   
      "." + (today.getMonth()+1) +  
      "." + today.getFullYear();        
      var data = {  
      name: "I am the One",   
      date: dateTxt,  
      comment: [  
           { description: "walking with you."  
           },   
           { description: "eating together."  
           },  
           { description: "driving around town."  
           },  
      ] };  
   $('body').html(this.homeTemplate(data));       
   },  
   initialize: function() {  
        var self = this;  
        var source = $("#a-comment").html();  
     self.showAlert('This is how its done','Info');  
     this.homeTemplate = Handlebars.compile(source);  
     this.renderHomeView();  
   }  

Alert Pop-up in PhoneGap

Using the native notification or browser alert pop-up

This is a continuation from the Previous notes: Creating an Android App with PhoneGap and Eclipse
Purpose: Display the Alert pop-up before the application display its contents.

Step 1: Create the main.js
In the project's assets/www create js folder, then create a new text file and name it as main.js
Place the following contents in assets/www/js/main.js

 var app = {  
      showAlert: function (message, title) {  
    if (navigator.notification) {  
     navigator.notification.alert(message, null, title, 'OK');  
    } else {  
     alert(title ? (title + ": " + message) : message);  
    }  
      },  
   initialize: function() {  
        var self = this;  
     self.showAlert('This is how its done','Info');  
   }  
 };  
 app.initialize();  

Step 2: Load main.js from index.html
Edit index.html. Immediately after the body tag place the following 1 line.

 <script src="js/main.js"></script>  

Step 3: Test the application.
See previous posting on how to do this.

Saturday, July 21, 2012

Blogger app from Google Inc needs a lot more of work.

Just installed the app on ICS.

It doesn't provide numbering list and other basic formatting.

My previous postings all appear in html edit view. No options visible to switch editing modes.

Option for tagging as labels are not very intuitive.

Possibly the developer is a single person from Google payroll or was it out sourced to India? Hmm....

Blog Archive