10 Jul 2015

Material Design Colors

This color palette comprises primary and accent colors that can be used for illustration or to develop your brand colors. They’ve been designed to work harmoniously with each other.
The color palette starts with primary colors and fills in the spectrum to create a complete and usable palette for Android, Web, and iOS. Google suggests using the 500 colors as the primary colors in your app and the other colors as accents colors.
Reference site :- Matrial Design Color

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="md_red_500_primary">#F44336</color>
    <!-- light -->
    <color name="md_red_50">#FFEBEE</color>
    <color name="md_red_100">#FFCDD2</color>
    <color name="md_red_200">#EF9A9A</color>
    <color name="md_red_300">#E57373</color>
    <color name="md_red_400">#EF5350</color>
    <!-- dark -->
    <color name="md_red_600">#E53935</color>
    <color name="md_red_700">#D32F2F</color>
    <color name="md_red_800">#C62828</color>
    <color name="md_red_900">#B71C1C</color>

    <!-- light -->
    <color name="md_red_a100">#FF8A80</color>
    <!-- dark -->
    <color name="md_red_a200">#FF5252</color>
    <color name="md_red_a400">#FF1744</color>
    <color name="md_red_a700">#D50000</color>


    <!-- PINK -->
    <!-- dark -->
    <color name="md_pink_500_primary">#E91E63</color>
    <color name="md_pink_50">#FCE4EC</color>
    <color name="md_pink_100">#F8BBD0</color>
    <color name="md_pink_200">#F48FB1</color>
    <color name="md_pink_300">#F06292</color>
    <color name="md_pink_400">#EC407A</color>
    <!-- dark -->
    <color name="md_pink_600">#D81B60</color>
    <color name="md_pink_700">#C2185B</color>
    <color name="md_pink_800">#AD1457</color>
    <color name="md_pink_900">#880E4F</color>

    <!-- light -->
    <color name="md_pink_A100">#FF80AB</color>
    <!-- dark -->
    <color name="md_pink_A200">#FF4081</color>
    <color name="md_pink_A400">#F50057</color>
    <color name="md_pink_A700">#C51162</color>


    <!-- PURPLE -->
    <!-- dark -->
    <color name="md_purple_500_primary">#9C27B0</color>
    <!-- light -->
    <color name="md_purple_50">#F3E5F5</color>
    <color name="md_purple_100">#E1BEE7</color>
    <color name="md_purple_200">#CE93D8</color>
    <!-- dark -->
    <color name="md_purple_300">#BA68C8</color>
    <color name="md_purple_400">#AB47BC</color>
    <color name="md_purple_600">#8E24AA</color>
    <color name="md_purple_700">#7B1FA2</color>
    <color name="md_purple_800">#6A1B9A</color>
    <color name="md_purple_900">#4A148C</color>

    <!-- light -->
    <color name="md_purple_A100">#EA80FC</color>
    <!-- dark -->
    <color name="md_purple_A200">#E040FB</color>
    <color name="md_purple_A400">#D500F9</color>
    <color name="md_purple_A700">#AA00FF</color>


    <!-- DEEP PURPLE-->
    <!-- dark -->
    <color name="md_deep_purple_500_primary">#673AB7</color>
    <!-- light -->
    <color name="md_deep_purple_50">#EDE7F6</color>
    <color name="md_deep_purple_100">#D1C4E9</color>
    <color name="md_deep_purple_200">#B39DDB</color>
    <!-- dark -->
    <color name="md_deep_purple_300">#9575CD</color>
    <color name="md_deep_purple_400">#7E57C2</color>
    <color name="md_deep_purple_600">#5E35B1</color>
    <color name="md_deep_purple_700">#512DA8</color>
    <color name="md_deep_purple_800">#4527A0</color>
    <color name="md_deep_purple_900">#311B92</color>

    <!-- light -->
    <color name="md_deep_purple_A100">#B388FF</color>
    <!-- dark -->
    <color name="md_deep_purple_A200">#7C4DFF</color>
    <color name="md_deep_purple_A400">#651FFF</color>
    <color name="md_deep_purple_A700">#6200EA</color>


    <!-- INDIGO -->
    <!-- dark -->
    <color name="md_indigo_500_primary">#3F51B5</color>
    <!-- light -->
    <color name="md_indigo_50">#E8EAF6</color>
    <color name="md_indigo_100">#C5CAE9</color>
    <color name="md_indigo_200">#9FA8DA</color>
    <!-- dark -->
    <color name="md_indigo_300">#7986CB</color>
    <color name="md_indigo_400">#5C6BC0</color>
    <color name="md_indigo_600">#3949AB</color>
    <color name="md_indigo_700">#303F9F</color>
    <color name="md_indigo_800">#283593</color>
    <color name="md_indigo_900">#1A237E</color>

    <!-- light -->
    <color name="md_indigo_A100">#8C9EFF</color>
    <!-- dark -->
    <color name="md_indigo_A200">#536DFE</color>
    <color name="md_indigo_A400">#3D5AFE</color>
    <color name="md_indigo_A700">#304FFE</color>


    <!-- BLUE -->
    <!-- dark -->
    <color name="md_blue_500_primary">#2196F3</color>
    <!-- light -->
    <color name="md_blue_50">#E3F2FD</color>
    <color name="md_blue_100">#BBDEFB</color>
    <color name="md_blue_200">#90CAF9</color>
    <color name="md_blue_300">#64B5F6</color>
    <color name="md_blue_400">#42A5F5</color>
    <!-- dark -->
    <color name="md_blue_600">#1E88E5</color>
    <color name="md_blue_700">#1976D2</color>
    <color name="md_blue_800">#1565C0</color>
    <color name="md_blue_900">#0D47A1</color>

    <!-- dark -->
    <color name="md_blue_A100">#82B1FF</color>
    <!-- light -->
    <color name="md_blue_A200">#448AFF</color>
    <color name="md_blue_A400">#2979FF</color>
    <color name="md_blue_A700">#2962FF</color>


    <!-- LIGHT BLUE -->
    <!-- dark -->
    <color name="md_light_blue_500_primary">#03A9F4</color>
    <!-- light -->
    <color name="md_light_blue_50">#E1F5FE</color>
    <color name="md_light_blue_100">#B3E5FC</color>
    <color name="md_light_blue_200">#81D4FA</color>
    <color name="md_light_blue_300">#4FC3F7</color>
    <color name="md_light_blue_400">#29B6F6</color>
    <!-- dark -->
    <color name="md_light_blue_600">#039BE5</color>
    <color name="md_light_blue_700">#0288D1</color>
    <color name="md_light_blue_800">#0277BD</color>
    <color name="md_light_blue_900">#01579B</color>

    <!-- light -->
    <color name="md_light_blue_A100">#80D8FF</color>
    <color name="md_light_blue_A200">#40C4FF</color>
    <color name="md_light_blue_A400">#00B0FF</color>
    <!-- dark -->
    <color name="md_light_blue_A700">#0091EA</color>


    <!-- CYAN -->
    <!-- dark -->
    <color name="md_cyan_500_primary">#00BCD4</color>
    <!-- light -->
    <color name="md_cyan_50">#E0F7FA</color>
    <color name="md_cyan_100">#B2EBF2</color>
    <color name="md_cyan_200">#80DEEA</color>
    <color name="md_cyan_300">#4DD0E1</color>
    <color name="md_cyan_400">#26C6DA</color>
    <!-- dark -->
    <color name="md_cyan_600">#00ACC1</color>
    <color name="md_cyan_700">#0097A7</color>
    <color name="md_cyan_800">#00838F</color>
    <color name="md_cyan_900">#006064</color>

    <!-- light -->
    <color name="md_cyan_A100">#84FFFF</color>
    <color name="md_cyan_A200">#18FFFF</color>
    <color name="md_cyan_A400">#00E5FF</color>
    <color name="md_cyan_A700">#00B8D4</color>


    <!-- TEAL -->
    <!-- dark -->
    <color name="md_teal_500_primary">#009688</color>
    <!-- light -->
    <color name="md_teal_50">#E0F2F1</color>
    <color name="md_teal_100">#B2DFDB</color>
    <color name="md_teal_200">#80CBC4</color>
    <color name="md_teal_300">#4DB6AC</color>
    <color name="md_teal_400">#26A69A</color>
    <!-- dark -->
    <color name="md_teal_600">#00897B</color>
    <color name="md_teal_700">#00796B</color>
    <color name="md_teal_800">#00695C</color>
    <color name="md_teal_900">#004D40</color>

    <!-- light -->
    <color name="md_teal_A100">#A7FFEB</color>
    <color name="md_teal_A200">#64FFDA</color>
    <color name="md_teal_A400">#1DE9B6</color>
    <color name="md_teal_A700">#00BFA5</color>

    <!-- GREEN -->
    <!-- dark -->
    <color name="md_green_500_primary">#4CAF50</color>
    <!-- light -->
    <color name="md_green_50">#E8F5E9</color>
    <color name="md_green_100">#C8E6C9</color>
    <color name="md_green_200">#A5D6A7</color>
    <color name="md_green_300">#81C784</color>
    <color name="md_green_400">#66BB6A</color>
    <!-- dark -->
    <color name="md_green_600">#43A047</color>
    <color name="md_green_700">#388E3C</color>
    <color name="md_green_800">#2E7D32</color>
    <color name="md_green_900">#1B5E20</color>

    <!-- light -->
    <color name="md_green_A100">#B9F6CA</color>
    <color name="md_green_A200">#69F0AE</color>
    <color name="md_green_A400">#00E676</color>
    <color name="md_green_A700">#00C853</color>


    <!-- LIGHT GREEN -->
    <!-- dark -->
    <color name="md_light_green_500_primary">#8BC34A</color>
    <!-- light -->
    <color name="md_light_green_50">#F1F8E9</color>
    <color name="md_light_green_100">#DCEDC8</color>
    <color name="md_light_green_200">#C5E1A5</color>
    <color name="md_light_green_300">#AED581</color>
    <color name="md_light_green_400">#9CCC65</color>
    <color name="md_light_green_600">#7CB342</color>
    <color name="md_light_green_700">#689F38</color>
    <!-- dark -->
    <color name="md_light_green_800">#558B2F</color>
    <color name="md_light_green_900">#33691E</color>

    <!-- light -->
    <color name="md_light_green_A100">#CCFF90</color>
    <color name="md_light_green_A200">#B2FF59</color>
    <color name="md_light_green_A400">#76FF03</color>
    <color name="md_light_green_A700">#64DD17</color>


    <!-- LIME -->
    <!-- light -->
    <color name="md_lime_500_primary">#CDDC39</color>
    <color name="md_lime_50">#F9FBE7</color>
    <color name="md_lime_100">#F0F4C3</color>
    <color name="md_lime_200">#E6EE9C</color>
    <color name="md_lime_300">#DCE775</color>
    <color name="md_lime_400">#D4E157</color>
    <color name="md_lime_600">#C0CA33</color>
    <color name="md_lime_700">#AFB42B</color>
    <color name="md_lime_800">#9E9D24</color>
    <!-- dark -->
    <color name="md_lime_900">#827717</color>

    <!-- light -->
    <color name="md_lime_A100">#F4FF81</color>
    <color name="md_lime_A200">#EEFF41</color>
    <color name="md_lime_A400">#C6FF00</color>
    <color name="md_lime_A700">#AEEA00</color>


    <!-- YELLOW -->
    <!-- light -->
    <color name="md_yellow_500_primary">#FFEB3B</color>
    <color name="md_yellow_50">#FFFDE7</color>
    <color name="md_yellow_100">#FFF9C4</color>
    <color name="md_yellow_200">#FFF59D</color>
    <color name="md_yellow_300">#FFF176</color>
    <color name="md_yellow_400">#FFEE58</color>
    <color name="md_yellow_600">#F9A825</color>
    <color name="md_yellow_700">#FBC02D</color>
    <color name="md_yellow_800">#F9A825</color>
    <color name="md_yellow_900">#F57F17</color>

    <color name="md_yellow_A100">#FFFF8D</color>
    <color name="md_yellow_A200">#FFFF00</color>
    <color name="md_yellow_A400">#FFEA00</color>
    <color name="md_yellow_A700">#FFD600</color>


    <!-- Amber -->
    <!-- light -->
    <color name="md_amber_500_primary">#FFC107</color>
    <color name="md_amber_50">#FFF8E1</color>
    <color name="md_amber_100">#FFECB3</color>
    <color name="md_amber_200">#FFE082</color>
    <color name="md_amber_300">#FFD54F</color>
    <color name="md_amber_400">#FFCA28</color>
    <color name="md_amber_600">#FFB300</color>
    <color name="md_amber_700">#FFA000</color>
    <color name="md_amber_800">#FF8F00</color>
    <color name="md_amber_900">#FF6F00</color>

    <color name="md_amber_A100">#FFE57F</color>
    <color name="md_amber_A200">#FFD740</color>
    <color name="md_amber_A400">#FFC400</color>
    <color name="md_amber_A700">#FFAB00</color>


    <!-- ORANGE -->
    <!-- light -->
    <color name="md_orange_500_primary">#FF9800</color>
    <color name="md_orange_50">#FFF3E0</color>
    <color name="md_orange_100">#FFE0B2</color>
    <color name="md_orange_200">#FFCC80</color>
    <color name="md_orange_300">#FFB74D</color>
    <color name="md_orange_400">#FFA726</color>
    <color name="md_orange_600">#FB8C00</color>
    <color name="md_orange_700">#F57C00</color>
    <!-- dark -->
    <color name="md_orange_800">#EF6C00</color>
    <color name="md_orange_900">#E65100</color>

    <!-- light -->
    <color name="md_orange_A100">#FFD180</color>
    <color name="md_orange_A200">#FFAB40</color>
    <color name="md_orange_A400">#FF9100</color>
    <color name="md_orange_A700">#FF6D00</color>


    <!-- DEEP ORANGE-->
    <!-- dark -->
    <color name="md_deep_orange_500_primary">#FF5722</color>
    <!-- light -->
    <color name="md_deep_orange_50">#FBE9E7</color>
    <color name="md_deep_orange_100">#FFCCBC</color>
    <color name="md_deep_orange_200">#FFAB91</color>
    <color name="md_deep_orange_300">#FF8A65</color>
    <color name="md_deep_orange_400">#FF7043</color>
    <!-- dark -->
    <color name="md_deep_orange_600">#F4511E</color>
    <color name="md_deep_orange_700">#E64A19</color>
    <color name="md_deep_orange_800">#D84315</color>
    <color name="md_deep_orange_900">#BF360C</color>

    <color name="md_deep_orange_A100">#FF9E80</color>
    <color name="md_deep_orange_A200">#FF6E40</color>
    <!-- light -->
    <color name="md_deep_orange_A400">#FF3D00</color>
    <color name="md_deep_orange_A700">#DD2C00</color>


    <!-- BROWN -->
    <!-- dark -->
    <color name="md_brown_500_primary">#795548</color>
    <!-- light -->
    <color name="md_brown_50">#EFEBE9</color>
    <color name="md_brown_100">#D7CCC8</color>
    <color name="md_brown_200">#BCAAA4</color>
    <!-- dark -->
    <color name="md_brown_300">#A1887F</color>
    <color name="md_brown_400">#8D6E63</color>
    <color name="md_brown_600">#6D4C41</color>
    <color name="md_brown_700">#5D4037</color>
    <color name="md_brown_800">#4E342E</color>
    <color name="md_brown_900">#3E2723</color>

    <!-- GREY -->
    <!-- light -->
    <color name="md_grey_500_primary">#9E9E9E</color>
    <color name="md_grey_50">#FAFAFA</color>
    <color name="md_grey_100">#F5F5F5</color>
    <color name="md_grey_200">#EEEEEE</color>
    <color name="md_grey_300">#E0E0E0</color>
    <color name="md_grey_400">#BDBDBD</color>
    <!-- dark -->
    <color name="md_grey_600">#757575</color>
    <color name="md_grey_700">#616161</color>
    <color name="md_grey_800">#424242</color>
    <color name="md_grey_900">#212121</color>


    <!-- BLUE GRAY -->
    <!-- dark -->
    <color name="md_blue_grey_500_primary">#607D8B</color>
    <!-- light -->
    <color name="md_blue_grey_50">#ECEFF1</color>
    <color name="md_blue_grey_100">#CFD8DC</color>
    <color name="md_blue_grey_200">#B0BEC5</color>
    <color name="md_blue_grey_300">#90A4AE</color>
    <!-- dark -->
    <color name="md_blue_grey_400">#78909C</color>
    <color name="md_blue_grey_600">#546E7A</color>
    <color name="md_blue_grey_700">#455A64</color>
    <color name="md_blue_grey_800">#37474F</color>
    <color name="md_blue_grey_900">#263238</color>

    <color name="md_black">#000000</color>
    <color name="md_white">#FFFFFF</color>

</resources>

Read More !

8 Jul 2015

What is the use of Intent Filter

An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle. It opens the component to receiving intents of the advertised type, while filtering out those that are not meaningful for the component.  

<activity
    android:name="com.amar.deep.ShareActivity"
    android:label="@string/title_activity_share" >
    <intent-filter>    
 <action android:name="android.intent.action.SEND" />
      <category android:name="android.intent.category.DEFAULT" />
      <data android:mimeType="text/plain" />
    </intent-filter>
</activity>


There are following test Android checks before invoking an activity:
  • A filter may list more than one action as shown above but this list cannot be empty; a filter must contain at least one element, otherwise it will block all intents. If more than one actions are mentioned then Android tries to match one of the mentioned actions before invoking the activity.
  • A filter may list zero, one or more than one categories. if there is no category mentioned then Android always pass this test but if more than one categories are mentioned then for an intent to pass the category test, every category in the Intent object must match a category in the filter.
  • Each element can specify a URI and a data type (MIME media type). There are separate attributes like scheme, host, port, and path for each part of the URI. An Intent object that contains both a URI and a data type passes the data type part of the test only if its type matches a type listed in the filter.                         
Action which is the most reasonable action to perform and Data that contains the basic information that drives our action were pretty easy to comprehend but Category is something that might need a bit of an explanation. Using the category attribute, we give/mention additional information about the action to execute (that’ll be matched for intent resolution). Examples:
  • CATEGORY_LAUNCHER – Show up in the Launcher (Google Experience Launcher or Google Now Launcher or Nova or some other that you installed and use) as a top-level application. In other words the activity is the initial activity of a task (will launch when app starts) and is listed in the system’s application launcher (app drawer).
  • CATEGORY_BROWSABLE – Activities that can be safely invoked from a browser when a user clicks on a hyperlink.
  • CATEGORY_ALTERNATIVE – Activity should be included in a list of alternative actions the user can perform on a piece of data. So for instance if your code doesn’t specifies the intent action but sets this category and there’s an intent filter with this category too (but some other intent action name) then without even knowing the action name that intent filter will match with the implicit intent and deliver it to the component.
  • CATEGORY_DEFAULT – The docs is a little hard to understand compared to this much simplerexplanation. The CATEGORY_DEFAULT category is applied to all implicit intents (automatically) passed to startActivity() and startActivityForResult(). So if you want your activity to receive implicit intents, it must include a category or "android.intent.category.DEFAULT" in its intent filters.


Read More !

4 Jul 2015

What is ANR? How to avoid application ANR?

ANR stands for A pplication N ot R esponding.
Android systems shows this dialog, if application is performing too much of task on main thread and been unresponsive for a long period of time.
ANR  is not exactly an error.It is shown when your application is very sluggish and takes a lot of time to respond making the user wait.The user won't appreciate if your application makes him wait for a long time so the android framework gives the user an option of closing your application.
This occurs when you are doing long running operations on the main thread and the system can't process user interactions during this period since the main thread is blocked.The solution is to do the heavy operations in a worker thread and keep the main thread free.

An ANR will occur if you are running a process on the UI thread which takes a long time, usually around 5 seconds. During this time the GUI (Graphical User Interface) will lock up which will result in anything the user presses will not be actioned. After the 5 seconds approx has occurred, if the thread still hasn't recovered then an ANR dialogue box is shown informing the user that the application is not responding and will give the user the choice to either wait, in the hope that the app will eventually recover, or to force close the app.
ANR in application is annoying to user. It can be caused due to various reasons. Below are some of the tips to avoid ANR
  • Perform all you long running network or database operation in separate thread
  • If you have too much of background tasks, then take it off the UI thread. You may use IntentService
  • Server not responding for longer period can be guilt for ANR. To avoid always define HTTP time out for your all your webs service calls.
  • Be watchful of infinite loops during your complex calculations

Read More !

2 Jul 2015

How to Use Shadow Effect on Android TextView

You can apply Shadow Effect on Android TextView in two ways. 
  1. Programmatically.
  2. Change in the xml layout.

Using Programmatically :-


TextView textview = (TextView) findViewById(R.id.textview2);
textview.setShadowLayer(30, 0, 0, Color.RED);



Using XML Layout :-


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:padding="20dp" >

    <TextView
        android:id="@+id/textview1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:shadowColor="#000"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="50"
        android:text="Text Shadow Example1"
        android:textColor="#FBFBFB"
        android:textSize="28dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/textview2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="Text Shadow Example2"
        android:textColor="#FBFBFB"
        android:textSize="28dp"
        android:textStyle="bold" />

</LinearLayout>
In the above XML layout code, the textview1 is given with Shadow effect in the layout. below are the configuration items are
  • android:shadowDx – specifies the X-axis offset of shadow. You can give -/+ values, where -Dx draws a shadow on the left of text and +Dx on the right
  • android:shadowDy – it specifies the Y-axis offset of shadow. -Dy specifies a shadow above the text and +Dy specifies below the text.
  • android:shadowRadius – specifies how much the shadow should be blurred at the edges. Provide a small value if shadow needs to be prominent.
  • android:shadowColor – specifies the shadow color.

Output :-

Shadow In TextView


Read More !

28 Jun 2015

How to add jar file in android studio

File > New Module...
the next screen looks weird, like you are selecting some widget or something but keep it on the first picture and below scroll and find "Import JAR or .AAR Package

then give the path of jar file.


Ok.That's the right way.
Then  Import the module by File -> Project Structure -> Select your project under Modules -> Dependencies -> Click on + to add a module dependancy. select your module and hit ok.that's it.




Read More !