Sunday 26 January 2014

Android emulator Internet Speed configuration

These days almost all apps need internet connect, its essential to test our application behavior on various internet connection speed. This is possible through Android emulator. Which gives an option to select internet speed.

The common internet speed provided by Android Emulator are
1. Full
2. GSM
3. HSCSD
4. GPRS
5. EDGE
6. UTMS
7. HSPDA

How to configure Emulator Internet Speed?

Eclipse then Run tab then Run Configurations



then select Target tab as shown in image. 


Scroll down you will see the emulators that you created and Network Speed and Network Latency combo box . 

Select any internet speed and say apply. 

Now your emulator is ready to run with configured internet speed. 

Enjoy testing your app. 


Tuesday 21 January 2014

Dropbox file upload

Dropbox API integration Android 


Dropbox is a free service that lets you bring your photos, docs, and videos anywhere and share them easily. 

You can integrate Dropbox in your app & upload file directly into Dropbox

Its helpful for those who doesn't have server or web space. The free upload data is 2GB from Dropbox

To start with DropBox API

  • Create your account in Dropbox
  • Generate App Key & Secrete Key 
  • Download the SDK from Dropbox
  • Change App Key & Secrete Key 


Create your account in Dropbox

Go to www.dropbox.com/, then create an account, Initially Dropbox provides you 2GB of space free!
Click on Developers Tab

Click on App Console, Now you will be able to see this screen 



Generate App Key & Secrete Key 


Click on Dropbox API app & select Files & Datastores

Can your app be limited to its own, private folder? 
Say Yes

Now click on Create App

Now you done with app creation. Now you will be able to see this screen



Download the SDK from Dropbox

Download the SDK from here
Extract & import into your workspace



Change App Key & Secrete Key 

Change both the keys which are present in DBRoulette.java class

Which are defined like this

 final static private String APP_KEY = "Change_here";

 final static private String APP_SECRET = "Change_here";

Now make changes in AndroidManifest.xml as well

 <data android:scheme="db-Change_here" /> 
In the above tag pug App_Key

Now your app is ready to upload file to Dropbox.



Click on Link With Dropbox, it will redirect do Dropbox page ask your permission to access the folder. 



Customize your code as per you want. 

Monday 20 January 2014

Android SQLite data to CSV format

SQLite to CSV

Its easy to export your current SQLite data into Excel or CSV format.

This can be achieved by simple code, which includes csv text file format, which we need to write through code.

CSV format works on the basis of comma and new line.

The below code includes.
1. File creation
2. Writing data to file
3. Fetching data from SQLite & writing in csv format.

You can modify your format however you want, keeping in your mind about commas.

Call this method & pass your file & directory path.



private Boolean backupDatabaseCSV(String outFileName) {
    MyLog.d(TAG, "backupDatabaseCSV");
    Boolean returnCode = false;
    int i = 0;
    String csvHeader = "";
    String csvValues = "";
    for (i = 0; i < GC.CURCOND_COLUMN_NAMES.length; i++) {
        if (csvHeader.length() > 0) {
            csvHeader += ",";
        }
        csvHeader += "\"" + GC.CURCOND_COLUMN_NAMES[i] + "\"";
    }

    csvHeader += "\n";
    MyLog.d(TAG, "header=" + csvHeader);
    dbAdapter.open();
    try {
        File outFile = new File(outFileName);
        FileWriter fileWriter = new FileWriter(outFile);
        BufferedWriter out = new BufferedWriter(fileWriter);
        Cursor cursor = dbAdapter.getAllRows();
        if (cursor != null) {
            out.write(csvHeader);
            while (cursor.moveToNext()) {
                csvValues = Long.toString(cursor.getLong(0)) + ",";
                csvValues += Double.toString(cursor.getDouble(1))
                        + ",";
                csvValues += Double.toString(cursor.getDouble(2))
                        + ",";
                csvValues += "\"" + cursor.getString(3) + "\",";
                csvValues += Double.toString(cursor.getDouble(4))
                        + ",";
                csvValues += Double.toString(cursor.getDouble(5))
                        + ",";
                csvValues += "\"" + cursor.getString(6) + "\",";
                csvValues += Double.toString(cursor.getDouble(7))
                        + ",";
                csvValues += Double.toString(cursor.getDouble(8))
                        + ",";
                csvValues += Double.toString(cursor.getDouble(9))
                        + "\n";
                out.write(csvValues);
            }
            cursor.close();
        }
        out.close();
        returnCode = true;
    } catch (IOException e) {
        returnCode = false;
        MyLog.d(TAG, "IOException: " + e.getMessage());
    }
    dbAdapter.close();
    return returnCode;
}

Enjoy converting SQLite to CSV.

Saturday 18 January 2014

Andriod Development Multi screen support

As Android is a big fragments and also there are number of manufactures, which results into number of screens, which varies from manufactures to manufactures and device to device. Its the responsibility of Android developer to his app responsive, here is the collection of drawable folders which are specific to support particular screens.

Here is the demonstration to how to develop multi screen application for your project.




Few of the drawable folders are as follows

  1. drawable
  2. drawable-ldpi
  3. drawable-mdpi
  4. drawable-hdpi
  5. drawable-xhdpi
  6. drawable-xxhdpi
  7. drawable-large-mdpi
  8. drawable-large-hdpi
  9. drawable-xlarge-mdpi
  10. drawable-xlarge-hdpi

drawable
Common image folder to support all screens


drawable-ldpi
for small screens


drawable-mdpi
for medium screen phones


drawable-hdpi
for high definition screen phones


drawable-xhdpi
for very high definition screen phones


drawable-xxhdpi
for very high definition devices


drawable-large-mdpi
for 7" tablets


drawable-large-hdpi
for 7" tablets (Specially for Nexus7)


drawable-xlarge-mdpi
for 10" tablets

drawable-xlarge-hdpi
for 10" tables high resolution

so keep images in each folder & check what your device supports, happy designing. 

        Friday 17 January 2014

        Android Multiscreen support Layout folders

        Being an Android developer one should know the different layout folders.
        Layouts play an important role in UI concept of Android. 

        Here are the few layouts folders which are used to support different screen sizes like

        1. Small Screen phones
        2. Medium Screen phones
        3. Large Screen Phones
        4. 7" Tablets
        5. 10 " Tablets


        ·         res/layout/ 

        for Phones 



        ·         res/layout-port

        for Phones only portrait screen



        ·         res/layout-land

        for Phones only Landscape screen



        ·         res/layout-sw600dp/

        for 7" Tablets



        ·         res/layout-sw600dp-port/

        for 7" Tablets only portrait



        ·         res/layout-sw600dp-land/

        for 7" Tablets only landscape



        ·         res/layout-sw720dp/

        for 10" Tablets



        ·         res/layout-sw720dp-port/

        for 10" Tablets only portrait



        ·         res/layout-sw720dp-land/

        for 10" Tablets only landscape



        ·         res/layout-xlarge/

        for pre 3.2" Tablets 




        ·         res/layout-xlarge-port/

        for pre 3.2" Tablets to support portrait only




        ·         res/layout-xlarge-land/

        for pre 3.2" Tablets to support landscapre only




        ·         res/layout-small/

        for small screens 




        ·         res/layout-small-port/

        for small screens to support portrait screens only 




        ·         res/layout-small-land/

        for small screens to support landscape screens only 




        ·         res/layout-large/

        for large screens 



        ·         res/layout-large-port/

        for large screens to support portrait screens only 



        ·         res/layout-large-land/
        for large screens to support landscape screens only