Sunday 31 May 2015

HB Blog 75: Buzzbox SDK Hello World Implementation.

The BuzzBox SDK enables you to easily add a scheduler to your App. With few lines of code you can add a background task and app-side notifications. Besides, BuzzBox SDK also include free realtime analytics, so you can monitor in real time how many user are installing and using your App. Notifications and Analytics are tighly integrated, but you can use only want you need. The developer needs to do very little work to provide value to the user and also increase retention, visits/user and perceived value of the product. The app-side notifications do not require any server side code, so the implementation costs are minimal. The SDK is modularized, so it can be customized by the developer.

BuzzBox SDK has below features:-

Scheduler: 
It allows you to run a background task up to every minute according to a cron string (i.e. "0 8-19 1,2,3,4,5" will run every hour, from 8am to 7pm, Monday - Friday).

Notifications Settings:
It has advanced notification settings with optional configurable UI for users.

Integrated Rss Parser: 
It give you the possibility to monitor whatever Rss feed providing you an implemented Rss Parser Task.

Notifications Log: 
You can check if and when yours backgrounds task are running.

Notification Types: 
Your app can support different type of notifications configurable by the user through the easy and completed UI.

Refer the below link for complete sample code:-
Download Sample Code
Download Apk File
Download Support Library

Have a look on few code snippets, 
AndroidManifest.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.buzzbox.demo.helloworld"
      android:versionCode="1"
      android:versionName="1.0">
      
    <uses-sdk android:minSdkVersion="3" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    
    <application android:icon="@drawable/icon_notification_cards_clubs" android:label="@string/app_name">
        <activity android:name=".HelloWorldActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

  <activity android:name="com.buzzbox.mob.android.scheduler.NotificationClickActivity"/>
        <activity android:name="com.buzzbox.mob.android.scheduler.ui.SchedulerPreferenceActivity"/>
        <activity android:name="com.buzzbox.mob.android.scheduler.ui.SchedulerLogActivity"/>
        <receiver android:name="com.buzzbox.mob.android.scheduler.BootReceiverSchedulerManager">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>
        <receiver android:name="com.buzzbox.mob.android.scheduler.TimeChangeReceiver">
            <intent-filter>
                <action android:name="android.intent.action.TIME_SET"/>
                <action android:name="android.intent.action.DATE_CHANGED"/>
                <action android:name="android.intent.action.TIMEZONE_CHANGED"/>
            </intent-filter>
        </receiver>
        <receiver android:name="com.buzzbox.mob.android.scheduler.AlarmReceiver"/>
        <service android:name="com.buzzbox.mob.android.scheduler.ScheduledService"/>
        
        <meta-data android:name="Scheduler.Analytics.apiKey" android:value="debug-api-key"/> <!-- sign up at http://hub.buzzbox.com and get your ApiKey -->
        
    </application>
</manifest>

ReminderTask.java
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import android.content.ContextWrapper;

import com.buzzbox.mob.android.scheduler.NotificationMessage;
import com.buzzbox.mob.android.scheduler.Task;
import com.buzzbox.mob.android.scheduler.TaskResult;

/**
 * Recurring Task that implements your business logic.
 * The BuzzBox SDK Scheduler will take care of running the doWork method according to
 * the scheduling.
 * 
 */
public class ReminderTask implements Task {

 @Override
    public String getTitle() {                        
        return "Reminder";
    }
    
    @Override
    public String getId() {                        
        return "reminder"; // give it an ID
    }
    
    @Override
    public TaskResult doWork(ContextWrapper ctx) {
        TaskResult res = new TaskResult();
       
        // TODO implement your business logic here
        // i.e. query the DB, connect to a web service using HttpUtils, etc..
        
        NotificationMessage notification = new NotificationMessage(
          "HB Demo",
          "Don't forget to open HB Demo App");
        notification.notificationIconResource = R.drawable.icon_notification_cards_clubs;
        notification.setNotificationClickIntentClass(HelloWorldActivity.class);
        
        res.addMessage( notification );    
        
        return res;
    }
 
}

HelloWorldActivity.java
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;

import com.buzzbox.mob.android.scheduler.SchedulerManager;
import com.buzzbox.mob.android.scheduler.analytics.AnalyticsManager;
import com.buzzbox.mob.android.scheduler.ui.SchedulerLogActivity;

public class HelloWorldActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  setContentView(R.layout.main);

  // 1. call BuzzBox Analytics
  int openAppStatus = AnalyticsManager.onOpenApp(this); 

  // 2. add the Task to the Scheduler
  if (openAppStatus==AnalyticsManager.OPEN_APP_FIRST_TIME) { 
        // register the Task when the App in installed
        SchedulerManager.getInstance().saveTask(this, 
          "*/1 * * * *",   // a cron string
          ReminderTask.class);
        SchedulerManager.getInstance().restart(this, ReminderTask.class );
  } else if (openAppStatus==AnalyticsManager.OPEN_APP_UPGRADE){
       // restart on upgrade
      SchedulerManager.getInstance().restartAll(this, 0);    
  }
  
  
  // 3. set up UI buttons
        Button settingsButton = (Button) findViewById(R.id.settings);
        settingsButton.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    SchedulerManager.getInstance()
          .startConfigurationActivity(HelloWorldActivity.this, ReminderTask.class);
   }
  });
        
        Button log = (Button) findViewById(R.id.log);
        log.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
    Intent intent = new Intent(HelloWorldActivity.this, SchedulerLogActivity.class);
    startActivity(intent);
   }
  });   
        
        Button refresh = (Button) findViewById(R.id.notify);
        refresh.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
    SchedulerManager.getInstance().runNow(HelloWorldActivity.this, ReminderTask.class, 0);
   }
  }); 
        
 }
 
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {        
        super.onActivityResult(requestCode, resultCode, data);        
        if (SchedulerManager.SCHEDULER_CONFIG_REQ_CODE == requestCode && data!=null) {
            SchedulerManager.getInstance()
             .handleConfigurationResult(this, data);        
        }
    }
    
}

main.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
    android:layout_height="fill_parent">
 <LinearLayout 
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
 
 <TextView  
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="HB Demo"
     android:textSize="16sp"
     android:gravity="center_horizontal"
   android:textColor="#53B9FA"
   android:paddingTop="9dip"
     />    

 <Button android:id="@+id/settings"
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Notification Settings"
     android:layout_margin="7dip"/>
     
 <Button android:id="@+id/log"
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Scheduler Log"
     android:layout_margin="7dip"/>
     
 <Button android:id="@+id/notify"
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Notify Me!"
     android:layout_margin="7dip"/>
 
 <TextView    
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="HB Demo"
     android:textSize="16sp"
     android:gravity="center_horizontal"
     android:textColor="#aaaaaa"
     android:layout_marginTop="10dip"
     />
 </LinearLayout>
</ScrollView>

Sunday 24 May 2015

HB Blog 74: Project Structures In Android And iOS Platform.

 In computing, a directory structure is the way an operating system's file system and its files are displayed to the user. Files are typically displayed in a hierarchical tree structure.

Android Application Modules are the modules that eventually get built into the .apk files based on your build settings. They contain things such as application source code and resource files. Most code and resource files are generated for you by default, while others should be created if required.

 The following directories and files comprise an Android application module:
build/
    Contains build folders for the specified build variants. Stored in the main application module.
libs/
    Contains private libraries. Stored in the main application module.
src/
    Contains your stub Activity file, which is stored at src/main/java//ActivityName>.java. All other source code files (such as .java or .aidl files) go here as well.

androidTest/
    Contains the instrumentation tests.
main/java/com.>project<.>app<
    Contains Java code source for the app activities.
main/jni/
    Contains native code using the Java Native Interface (JNI).
main/gen/
    Contains the Java files generated by Android Studio, such as your R.java file and interfaces created from AIDL files.
main/assets/
    This is empty. You can use it to store raw asset files. Files that you save here are compiled into an .apk file as-is, and the original filename is preserved. You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the AssetManager.
main/res/
    Contains application resources, such as drawable files, layout files, and string values in the following directories.

    anim/
        For XML files that are compiled into animation objects.
    color/
        For XML files that describe colors.
    drawable/
        For bitmap files (PNG, JPEG, or GIF), 9-Patch image files, and XML files that describe Drawable shapes or Drawable objects that contain multiple states (normal, pressed, or focused).
    mipmap/
        For app launcher icons. The Android system retains the resources in this folder (and density-specific folders such as mipmap-xxxhdpi) regardless of the screen resolution of the device where your app is installed. This behavior allows launcher apps to pick the best resolution icon for your app to display on the home screen. For more information about using the mipmap folders, see Managing Launcher Icons as mipmap Resources.

    layout/
        XML files that are compiled into screen layouts (or part of a screen).
    menu/
        For XML files that define application menus.
    raw/
        For arbitrary raw asset files. Saving asset files here is essentially the same as saving them in the assets/ directory. The only difference is how you access them. These files are processed by aapt and must be referenced from the application using a resource identifier in the R class. For example, this is a good place for media, such as MP3 or Ogg files.
    values/
        For XML files that define resources by XML element type. Unlike other resources in the res/ directory, resources written to XML files in this folder are not referenced by the file name. Instead, the XML element type controls how the resources defined within the XML files are placed into the R class.
    xml/
        For miscellaneous XML files that configure application components. For example, an XML file that defines a PreferenceScreen, AppWidgetProviderInfo, or Searchability Metadata.

AndroidManifest.xml
    The control file that describes the nature of the application and each of its components. For instance, it describes: certain qualities about the activities, services, intent receivers, and content providers; what permissions are requested; what external libraries are needed; what device features are required, what API Levels are supported or required; and others.

.gitignore/
    Specifies the untracked files ignored by git.
app.iml/
    IntelliJ IDEA module
build.gradle
    Customizable properties for the build system. You can edit this file to override default build settings used by the manifest file and also set the location of your keystore and key alias so that the build tools can sign your application when building in release mode. This file is integral to the project, so maintain it in a source revision control system.
proguard-rules.pro
    ProGuard settings file.

In iOS, there is no industry standard as such. You could look into sample Apple Source Projects to see how they do it..
To keep all those hundreds of source files ending up in the same directory, it's a good idea to set up some folder structure depending on your architecture. For instance, you can use the following:
├─ Models
├─ Views
├─ Controllers
├─ Stores
├─ Helpers


You could also, try organizing your files into Groups & associate each group to a folder..
    Organize all Controllers in One Group with Subgroup for each usecase.
    Put all views in One Group and subgroup for each usecase.
    Organize All Models in one Group
    Put Third Party Libraries in Another Group with Subgroup for each Lib.

So on and So Forth.. Also, associate each group to a folder inside your project.
Have a look on below example,
+ App
  |
  |-- .gitignore
  |-- readme.md
  |-- license.txt
  |
  +-+ App.xcodeproj
  | +-- project.pbxproj
  |
  +-+ App
  | +-+ Classes
  | | |-- AppDelegate.h
  | | |-- AppDelegate.m
  | | |-- ViewController.h
  | | |-- ViewController.m
  | | +-- ViewController.xib
  | |
  | +-+ Resources
  | | |-- Info.plist
  | | |-- App.entitlements
  | | |-- About.html
  | | +-+ en.lproj
  | | | +-- InfoPlist.strings
  | | +-+ de.lproj
  | | | +-- InfoPlist.strings
  | | +-+ Images
  | |   |-- Default.png
  | |   +-- Default@2x.png
  | |
  | +-+ Other Sources
  | | |-- App-prefix.pch
  | | +-- main.m
  | |
  | +-+ External
  |   +-+ AFNetworking
  |   | |-- SomeFile.h
  |   | +-- SomeFile.m
  |   +-+ Sparkle
  |     |-- SomeOtherFile.h
  |     +-- SomeOtherFile.m
  |
  +-+ AppTests
    +-+ Classes
    | |-- TestCase1.h
    | +-- TestCase1.m
    |
    +-+ Resources
      |-- InfoPlist.strings
      +--AppTests-Info.plist

 If you're planning on including external dependencies (e.g. third-party libraries) in your project, CocoaPods offers easy and fast integration. Note in that case, you'll need to open the .xcworkspace file instead of .xcproject, or your code will not compile.

Sunday 17 May 2015

HB Blog 73: Inside The Mobile Phone.

A mobile phone is an electronic device used for mobile telecommunications over a cellular network of specialized base stations known as cell sites. A cell phone offers full Duplex Communication and transfer the link when the user moves from one cell to another. As the phone user moves from one cell area to another, the system automatically commands the mobile phone and a cell site with a stronger signal, to switch on to a new frequency in order to keep the link.
Mobile phone is primarily designed for Voice communication. In addition to the standard voice function, new generation mobile phones support many additional services, and accessories, such as SMS for text messaging, email, packet switching for access to the Internet, gaming, Bluetooth, camera with video recorder and MMS for sending and receiving photos and video, MP3 player, radio and GPS. 

Signal Frequency in Cell Phone
The cellular system is the division of an area into small cells.
This allows extensive frequency reuse across that area, so that many people can use cell phones simultaneously. Cellular networks has a number of advantages like increased capacity, reduced power usage, larger coverage area, reduced interference from other signals etc.

FDMA and CDMA Systems
Frequency Division Multiple Access (FDMA) and Code Division Multiple Access (CDMA) were developed to distinguish signals from several different transmitters. In FDMA, the transmitting and receiving frequencies used in each cell are different from the frequencies used in the neighboring cells. The principle of CDMA is more complex and the distributed transceivers can select one cell and listen to it. Other methods include Polarization Division Multiple Access (PDMA) and Time Division Multiple Access (TDMA). Time division multiple access is used in combination with either FDMA or CDMA to give multiple channels within the coverage area of a single cell.Mobile phone is a Duplex device. When we use one frequency for talking, a second separate frequency is used for listening. So that both the people on the call can talk at once. The Mobile phone can communicate on 1,664 channels or more. The Mobile phones operate within the cells, so that it is easy to switch on to different cells as they move around. A person using a cell phone can drive hundreds of kilometers and can maintain a conversation during the entire time because of the cellular approach.

Codes in the Mobile Phone
Mobile phones have special codes associated with them. These include:
  • Electronic Serial Number (ESN) -Unique 32-bit number programmed in the phone
  • Mobile Identification Number (MIN) - 10 digit number derived from the phone’s number.
  • System Identification Code (SID) – unique 5 digit number that is assigned to each carrier by the FCC.
ESN is a permanent part of the phone while MIN and SID codes are programmed in the phone when a service plan is selected and activated.

Activation of SIM Card
SIM card (Subscriber Identification Module (SIM)) is a type of Smart card used in mobile phone. The SIM is a detachable smart card containing the user’s subscription information and phone book. This allows the user to retain his or her information even after switching off the handset. Alternatively, the user can also change service providers while retaining the handset simply by changing the SIM. SIM card Securely stores the service subscriber key having 15 digits.
The digits of the key are :
  • First 3 digits – Mobile country code
  • Second 2 digits – Mobile network code
  • Third 10 digits – Mobile station identification number
Subscriber Identification Module SIM
When the Mobile phone is used for the first time, it sends a number called International Mobile Subscriber Identity – IMSI present in the SIM card to the network, which looks it up in a database to ensure the card is registered. If the IMSI is recognized, the network creates another number called a Temporary Mobile Subscriber Identity (TMSI), which is encrypted and sent back to the phone. In all subsequent calls, the phone identifies itself by broadcasting the TMSI. 

What happens when we make a call?
  1. When we switch on the mobile phone, it tries for an SID on the Control channel. The Control channel is a special frequency that the phone and base station use to talk to one another. If the Mobile phone finds difficulty to get link with the control channel, it displays a “no service” message.
  2. If the Mobile phone gets the SID, it compares the SID with the SID programmed in the phone. If both SID match, the phone identifies that the cell it is communicating is the part of its home system.
  3. The phone also transmits a registration request along with the SID and the MTSO keeps track of your phone’s location in a database. MTSO knows in which cell you are when it wants to ring the phone.
  4. The MTSO then gets the signal, it tries to find the phone. The MTSO looks in its database to find the cell in which the phone is present. The MTSO then picks a frequency pair to take the call.
  5. The MTSO communicates with the Mobile phone over the control channel to tell it what frequencies to use. Once the Mobile phone and the tower switch on those frequencies, the call is connected.
  6. When the Mobile phone move toward the edge of the cell, the cell’s base station will note that the signal strength is diminishing. At the same time, the base station in the cell in which the phone is moving will be able to see the phone’s signal strength increasing.
  7. The two base stations coordinate themselves through the MTSO. At some point, the Mobile phone gets a signal on a control channel and directs it to change frequencies. This will switch the phone to the new cell.
Inside the Mobile phone
Mobile phone is a sophisticated device using SMD components, Microprocessor, Flash memory etc. In addition to the Circuit board, Mobile phone also has Antenna, Liquid Crystal Display(LCD) , Keyboard, Microphone, Speaker and Battery. The circuit board is the heart of the Mobile phone. It has chips like Analog-to-Digital and Digital-to-Analog conversion chips that translate the outgoing audio signal from analog to digital and the incoming signal from digital back to analog.Following are the Chips present in Mobile phone.
1. Digital signal processor
It is generally rated as having 40 MIPS (millions of instructions per second) to conduct calculations of signal manipulation at high speed. This chip deals with both compression and decompression of the signals. 
2. Microprocessor
It handles all the housekeeping tasks for the keyboard and display. It also deals with command and control signaling with the base station, and coordinates the rest of the functions on the board.
3.The Flash memory and ROM Chips 
They act as a storage location for the phone. These chips store the customizable options of the cell phone, as well as the entire operating system. The power and radio frequency sections of the phone, phone recharging and power management etc are controlled by this chip. It also controls several hundred FM channels. The RF amplifiers focus on signals that go in and out of the phone’s antennae.

Saturday 9 May 2015

HB Blog 72: Inside The Cell Phone Jamming Device.

A mobile phone jammer is an instrument used to prevent cellular phones from receiving signals from base stations. When used, the jammer effectively disables cellular phones. These devices can be used in practically any location, but are found primarily in places where a phone call would be particularly disruptive because silence is expected. A jamming device transmits on the same radio frequencies as the cell phone, disrupting the communication between the phone and the cell-phone base station in the tower. It's a called a denial-of-service attack. The jammer denies service of the radio spectrum to the cell-phone users within range of the jamming device.


Cell Phone Jamming Device 
Jamming devices overpower the cell phone by transmitting a signal on the same frequency and at a high enough power that the two signals collide and cancel each other out. Cell phones are designed to add power if they experience low-level interference, so the jammer must recognize and match the power increase from the phone. Cell phones are full-duplex devices, which means they use two separate frequencies, one for talking and one for listening simultaneously. Some jammers block only one of the frequencies used by cell phones, which has the effect of blocking both. The phone is tricked into thinking there is no service because it can receive only one of the frequencies. Less complex devices block only one group of frequencies, while sophisticated jammers can block several types of networks at once to head off dual-mode or tri-mode phones that automatically switch among different network types to find an open signal. Some of the high-end devices block all frequencies at once, and others can be tuned to specific frequencies. To jam a cell phone, all you need is a device that broadcasts on the correct frequencies. Although different cellular systems process signals differently, all cell-phone networks use radio signals that can be interrupted. GSM, used in digital cellular and PCS-based systems, operates in the 900-MHz and 1800-MHz bands in Europe and Asia and in the 1900-MHz (sometimes referred to as 1.9-GHz) band in the United States. Jammers can broadcast on any frequency and are effective against AMPS, CDMA, TDMA, GSM, PCS, DCS, iDEN and Nextel systems. Old-fashioned analog cell phones and today's digital devices are equally susceptible to jamming. The actual range of the jammer depends on its power and the local environment, which may include hills or walls of a building that block the jamming signal. Low-powered jammers block calls in a range of about 30 feet (9 m). Higher-powered units create a cell-free zone as large as a football field. Units used by law enforcement can shut down service up to 1 mile (1.6 km) from the device.
Inside Cell Phone Jammers
 Electronically speaking, cell-phone jammers are very basic devices. The simplest just have an on/off switch and a light that indicates it's on. More complex devices have switches to activate jamming at different frequencies. Components of a jammer include:
Antenna
Every jamming device has an antenna to send the signal. Some are contained within an electrical cabinet. On stronger devices, antennas are external to provide longer range and may be tuned for individual frequencies.
Circuitry

The main electronic components of a jammer are:
  • Voltage-controlled oscillator - Generates the radio signal that will interfere with the cell phone signal
  • Tuning circuit - Controls the frequency at which the jammer broadcasts its signal by sending a particular voltage to the oscillator
  • Noise generator - Produces random electronic output in a specified frequency range to jam the cell-phone network signal (part of the tuning circuit)
  • RF amplification (gain stage) - Boosts the power of the radio frequency output to high enough levels to jam a signal
Power supply
Smaller jamming devices are battery operated. Some look like cell phone and use cell-phone batteries. Stronger devices can be plugged into a standard outlet or wired into a vehicle's electrical system.

Monday 4 May 2015

HB Blog 71: Active Android - ORM (Object Relational Mapper).

Object-relational mapping is a programming technique for converting data between incompatible type systems in object-oriented programming languages. ActiveAndroid is an active record style ORM (object relational mapper). ActiveAndroid allows you to save and retrieve SQLite database records without ever writing a single SQL statement. Each database record is wrapped neatly into a class with methods like save() and delete().

There are few below steps to follow for using ActiveAndroid :-
1)Add ActiveAndroid library to your project. If you're using Android Studio, drag the jar to the libs folder of project and select "Add as a Library…".
2)Modify your build.gradle as below,
1
2
3
4
5
6
repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'

3)Update Android Manifest file of your project for global setting as below,
1
2
3
4
5
6
7
8
<manifest>
    <application android:name="com.activeandroid.app.Application">

        <meta-data android:name="AA_DB_NAME" android:value="Pickrand.db" />
        <meta-data android:name="AA_DB_VERSION" android:value="5" />

    </application>
</manifest>

4)Just extend com.activeandroid.app.Application instead of android.app.Application or initialise using ActiveAndroid.initialize(this); in the Application class.
5)Finally the setup is completed and now you can now create the database model, create classes named your desired table name, which have annotated fields for each of the columns. Your class must extend the Model class and your members must be annotated using @Column. ActiveAndroid will handle primitive data types as well as relationships to other tables and date classes. ActiveAndroid creates an id field for your tables. This field is an auto-incrementing primary key.

Here is a sample example,
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
@Table(name = "Items")
public class Item extends Model {
        // If name is omitted, then the field name is used.
        @Column(name = "Name")
        public String name;

        @Column(name = "Category")
        public Category category;

        public Item() {
                super();
        }

        public Item(String name, Category category) {
                super();
                this.name = name;
                this.category = category;
        }
}