Saturday, April 27, 2013

Learn Amharic won Android Africa Challenge 2013(AAC 2013) National

Learn Amharic won national challenge and selected to represent Ethiopia in Africa Android Challenge 2013 . In the GDG Africa BARCAMP held at Addis Ababa University to celebrate the winner in collaboration with Google , ALCATEL ONE TOUCH and JCertif  I have received the prize.

I am very happy to represent Ethiopia in the challenge I will do my best to win AAC 2013.
 Thanks !!!!!!!!

Saturday, April 13, 2013

How to display Amharic font on android app

  1. Create new android project and name it AmharicFont
  2. Click next and leave everything as it is by default
  3. Open activity_main layout window drag and drop TextView and on the property window change id to textAmharic. The xml should look like this

    <TextView
            android:id="@+id/textAmharic"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14dp"
            android:layout_marginTop="30dp"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />
  4. Now define amharic string on the resource to do this, go to res/values/strings.xml file and the following line

    <string name="wellcom_msg">እንኳን ደህና መጡ!</string>
  5. Navigate to your project assets folder and create new folder named fonts inside
  6. Right click on fonts folder -> Import -> General ->File systems -> Navigate to your amharic font file and click ok. Now you have successfully embedded your font
  7. Open your java file named MainActivity.java in src folder
  8. Next to setContentView(R.layout.activity_main) put the following code snippet

 TextView tv=(TextView)findViewById(R.id.textAmharic);
tv.setText(getResources().getString(R.string.welcome_msg));
Typeface tf=Typeface.createFromAsset(getAssets(),"fonts/NYALA.TTF");
tv.setTypeface(tf);
Now run your application and enjoy.

Tuesday, April 2, 2013

Android Activity Quick Start


Android Activity Quick Start

Declaring Activity


 

1.       In Eclipse click File->New->Android Application Project

2.       Specify all  required infrmation as shown below

 

3.       Click Next antil you reached activity creation step, and specify activity information as shown below

 
4.Click finish, your project will be created as shown below.

 


4.       Open up the manifest file from the Package Explorer, and then click on the AndroidManifest.xml tab at the bottom to display the code that the IDE has produced.

Within the <activity> element, find the following attributes:

android:name=".MainActivity"

android:label="@string/app_name"

5.       Edit the code so that it matches the following snippet:

<activity

android:name=".MainActivity"

android:label="Welcome to Android Introduction"

android:screenOrientation="portrait">

...

</activity>

6.       To run your application you need to create android virtual device , to do so click “Android Virtual Device Manager” from task bar as shown in the figure below.


7.       You will be presented with virtual device manager as shown below



8.       Click New and create new emulator and start .

9.       Now close all the dialog except the emulator , and return to your Eclipse IDE

10.   To run your application click Run ->Run

Starting a new activity with an intent object


 

1.       Now from package explorer go to res->layout and open main.xml 

2.       Next  to </TextView>  Insert button as shown below

<Button

        android:id="@+id/callButton"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:text="Call Log" />

3.       Save and close

4.       From package explorer got src and open MainActivity.java and put the following method at the end inside the class               

                void startCallButton () {

       Intent myIntent = new Intent();

       myIntent.setAction(Intent.ACTION_CALL_BUTTON);

       startActivity(myIntent);

5.       Insert button click event listener  code show bellow in to onCreate() method  next setContentView()

                                Button cButton=(Button)findViewById(R.id.callButton);

              cButton.setOnClickListener(new View.OnClickListener() {

                    

                     @Override

                     public void onClick(View arg0) {

                           // TODO Auto-generated method stub

                           startCallButton();

                          

                     }

              });

 

6.       Save the project and run,and click the button

7.       If this generates an error message, it may be that the correct libraries have not been imported. To use intents we have to import the relevant library, which can be done with import android.content.Intent; however it's easy to get Eclipse to import any missing libraries simply by pressing Shift + Ctrl + O.

 


 

Switching between activities


 

Often we will want to activate one activity from within another. Although this is not a difficult task, it will require more setting up than the previous two recipes as it will need two activities to be declared in the Manifest, a new Class to serve as our second activity, and a button along with a click listener to perform the switch.

1.       Create a new activity in the same location as the original activity subclass to do so:

                Right Click on your project->click New->click other

                You will be presented with the following dialog box.


2.       Select Android Activity and click next ->next until you reach new activity dialog box and

    Activity Name-  MySubActivity

   Layout Name – mysub

And leave everything as it is and click finish.

 

3.       Next, we must add a button that the user can click on to switch activities. This is set up through the main.xml file which resides in the res/layout folder in the Package Explorer.

4.       Open the main.xml file and click on the XML tab at the bottom so that the code can be edited.

5.       Add the following <Button> element just after the  call button from previous example y:

   <Button

       android:text="click to switch activities"

       android:id="@+id/main_activity_button"

       android:layout_width="wrap_content"

       android:layout_height="wrap_content">

       </Button>

6.       Now open the original Java activity class,.

7.       Add the following code to the onCreate() method after the setContentView(R. layout.main); statement, making sure to replace the package and class parameters in the setClassName() call with your own, as they will most likely be different:

             Button switchButton = (Button) findViewById(R.id.main_activity_button);

              switchButton.setOnClickListener(new View.OnClickListener() {

                     @Override

                     public void onClick(View v) {

                           Intent intent = new Intent();

                           String packageName =

                           "com.example.mysimpleapp ";

                           String className =

                           "com.example.mysimpleapp.MySubActivity";

                           intent.setClassName(packageName, className);

                           startActivity(intent);

                     }

              });

8.       Run the application on a device or emulator. Clicking on the button will now start the sub activity.

Passing Data from one activity to another


 

1.       Create a new project with these project name PassDataActivity. Leave everything else as it is by default and click finish.

2.        Open activity_main.xml and put EditText  and Button as shown below.

 

<EditText

        android:id="@+id/messageText"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:ems="10" >

 

        <requestFocus />

    </EditText>

 

    <Button

        android:id="@+id/sendButton"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Send" />

 

 

 

 

 

 

 

 

 

3.       In the package explorer open MainActivity.java and add the following code to the onCreate() method after the setContentView(R. layout.main);

 

Button mSendButton=(Button)findViewById(R.id.sendButton);

          mSendButton.setOnClickListener(new View.OnClickListener() {

                

                 @Override

                 public void onClick(View arg0) {

                        // TODO Auto-generated method stub

EditText    MessageText=(EditText)findViewById(R.id.messageText);

                        Intent intent= new Intent();

                    intent.setClassName("com.example.passdataactivity","com.example.passdataactivity.SecondActivity");

                        intent.putExtra("com_example_passdataactivity_id", mMessageText.getText().toString());

                        startActivity(intent);

                       

                 }

          });

 

4.       Now time to create our second activity, add new activity and name it SecondActivity. Leave everything as it and click finish.

 

5.       From package explorer Open SecondActivity.java and add the following code to the onCreate() method after the setContentView(R. layout.main);

 

String msg=getIntent().getExtras().getString("com_example_passdataactivity_id ");

              EditText msgView=new EditText(this);

              msgView.setText(msg);

          setContentView(msgView);

 

6.       Run the application on a device or an emulator.

Quick configuration with Android Bundle


Quick configuration with Android Bundle


The Android SDK providesyou the API libraries and developer tools necessary to build, test, and debugapps for Android.

 

If you're a new Android developer, we recommend youdownload the ADT Bundle to quickly start developing apps. It includes theessential Android SDK components and a version of the Eclipse IDE withbuilt-in ADT (Android Developer Tools) to streamline your Android appdevelopment. With a single download, the ADT Bundle includes everything youneed to begin developing apps:

 

 

·        Eclipse + ADT plugin

·        Android SDK Tools

·        Android Platform-tools

·        The latest Androidplatform

·        The latest Androidsystem image for the emulator

How to configure


1.   Download ADT Bundlefor your operating system from http://developer.android.com/sdk/index.html

2.   Unpack the ZIP file(named adt-bundle-<os_platform>.zip) and save it to an appropriate location, suchas a "Development" directory in your home directory.

3.   Open the adt-bundle-<os_platform>/eclipse/ directory and launch eclipse.

Monday, February 18, 2013

How to remove postgresql from ubuntu

1.get the list of package postgresql installed
dpkg -l | grep postgres
This will give you all the package
2. Now you will remove all package
sudo apt-get --purge remove postgresql
sudo apt-get --purge remove postgresql-9.1


You will remove all of them like shown above
3.your done enjoy

Wednesday, January 30, 2013

How to make OpenERP field unique

1.Assume you have inventory item definition on inventory.py
...............
_columns = {
'product_id' : fields.char('Product ID' , size=32 , required=True),
}
2. To make unique add the following line in the class

_sql_constraints=[( 'product_id_uniq', 'unique(product_id)' , 'Duplicate product id !')]

3.Enjoy

Thursday, January 17, 2013

Am enneagram type six


Recently my friend invited me to attend free enneagram session , this session was conducted by Enneagram Institute Ethiopia near CMC was eager to know what it is and at the same time i was not sure if am interested at all.

We have reached there on time and I was looking around wondering what am going to get , after a while two enneagram certified trainers started the session .After brief introduction about enneagram they started video guided discussion about 9 types in enneagram starting from one and so on , since they started this discussion I was so happy trying to label all friends and family on each types and of course wondering which type am going to fit,

Until type six is reached i couldn't relate to any but when six ,I was surprised and I had no word how to express what i felt it just me they are talking and I couldn't believe my behavior is stipulated and being told to me.

And it was quit good experience to know yourself , I learnt about my type in other dimension. i can use this to study my behavior and know more about my type for better personal development.

The trainer told us this session was a glimpse of the course , when the one month course is taken it will include more detailed explanation and how to interact with other types and so on.

What can I say thanks EIE for the enlightenment in this short period.