Wednesday, December 17, 2014

Android controlling EditText input

Description: coming soon..


  • imeOptions flagNoFullscreen
  • imeOptions actionDone
  • inputType textUri



        <EditText
            android:key="server_ip"
            android:title="server_ip"
            android:dialogTitle="@string/server_ip"
            android:contentDescription="Server IP"
            android:defaultValue="192.168.1.2"
            android:lines="1"
            android:imeOptions="flagNoFullscreen|actionDone"
            android:inputType="textUri"/>

Android: using AIDL

DEFINING AIDL OBJECTS


Let's say we want to define AIDL that we will use to communicate UI Fragment with AndroidService.

/** calls UI to Service **/
MyServiceAIDL.aidl

interface CommandServiceAIDL {
void setSomething(double value);
}



/** callbacks service to UI **/
MyListenerAIDL.aidl

interface MyListenerAIDL {
void onSomeEvent( boolean isOn);
}



ONCE YOU HAVE YOUR AIDL DEFINED



Let's say we have a UI Fragment

import android.content.ServiceConnection;

public class MyFragment extends Fragment implements ServiceConnection {
// ...
 @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
    // we have to BIND this UI to AIDL service
      getActivity().getApplicationContext().bindService(new Intent(CommandConst.ACTION_BIND_SERVICE), this, Context.BIND_AUTO_CREATE);
   }


// ...
@Override
   public void onDestroy() {
      super.onDestroy();
     // WE have to UNBIND this UI form AIDL service
      getActivity().getApplicationContext().unbindService(this);
   }



// class that has all my AIDL methods
private MyServiceAIDL myServiceAIDL;

@Override
   public void onServiceConnected(ComponentName name, IBinder service) {
   
      myServiceAIDL = MyServiceAIDL.Stub.asInterface(service);
      try {
         // register this fragment as a client of the AIDL service
         myServiceAIDL.register(TAG, myServiceAIDL Callback);
         myServiceAIDL.setSomething(123.5);
      }
      catch (RemoteException e) {
         Log.e(TAG, e.getMessage(), e);
      }
   }


private void doSomething(double value) {
         try {
            myServiceAIDL.setSomething(value);
         }
         catch (RemoteException e) {
            e.printStackTrace();
         }
      }


 // CALLBACKS

 private final MyListenerAIDL.Stub commandServiceCallback = new SimpleCommandServiceListener() {

     @Override
      public void onSomeEvent(final boolean isOn) throws RemoteException {
         handler.post(new Runnable() {
            @Override
            public void run() {
               if (someSwitch.isChecked() != isOn) {
                  someSwitch.setChecked(isOn);
               }
            }
         });
      }
}

Saturday, December 13, 2014

Android app deploying and monetizing

In this tutorial we will discuss what you need to do to deploy your app to the Google Play Market and how to make money $$$.

Monday, December 8, 2014

Android Studio: migrating to 1.0

Exciting moment -- Android Studio is not a baby anymore!
However, the rite of passage did not come without the growing pains.

Mac OS X: cpp tools

In this tutorial I will summarize how to install all tools needed to compile C++ code.

Install Apple's Command Line Tools:

$ xcode-select --install

xcode-select: error: command line tools are already installed, use "Software Update" to install updates




Saturday, December 6, 2014

SMS bid app



README.md

*************************************************
APP OVERVIEW
*************************************************

Use cases:
1) User creates offline list of items that will be used in an auction, example:
- sofa, pale blue, heavily used #sofa001
- mountain bike, barely used (I am developer not a sportsman) #bike002
- HTC ONE, Android phone, still working, AT&T #phone003
2) User distributes the list of bid items to FFF (family, friends and fools) by mailing, posting, etc.
3) User enters the bid items into the app
4) User enters the bid deadline per item into the app
6) User enters a minimum bid price per item into the app
7) FFF send SMS messages with bid in format:

bid #bike002 $30

8) The app tally up the highest bid and replies to FFF

- Minimum bid for item #bike002 is $30
- These is a higher bid for #bike002 in amount of $31

9) User can monitor the winning bids in the app

#sofa001
No bids

#bike002 minimum bid $30
- $31 from 6508151234
- $30 from 6508151432

10) there are many additional features you can add to this application


AndroidStudio: install *.md plugin

It is a common practice to provide a README text file in the root of the project.
The file usually specify:
- project overview
- project dependencies
- how to build the project
- copyrights

It is became the standard to write this file in a MarkDown format README.md

Once you create a new *.md text file the AndroidStudio tells you that it does not recognize the format and to download the plugin.

Monday, November 24, 2014

Android: checking IP of your devie

 adb shell netcfg

lo       UP                                   127.0.0.1/8   0x00000049 00:00:00:00:00:00
can0     UP                                     0.0.0.0/0   0x000000c1 00:00:00:00:00:00
can1     UP                                     0.0.0.0/0   0x000000c1 00:00:00:00:00:00
can2     UP                                     0.0.0.0/0   0x000000c1 00:00:00:00:00:00
can3     UP                                     0.0.0.0/0   0x000000c1 00:00:00:00:00:00
tunl0    DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
sit0     DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
ip6tnl0  DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00

eth0     UP                                     0.0.0.0/0   0x00001043 00:04:a3:de:e6:26

Saturday, November 22, 2014