Search This Blog

Tuesday, 30 December 2014

Best practices Android Resposiveness : Using background Intent service for background job

An IntentService isn't affected by most user interface lifecycle events, so it continues to run in circumstances that would shut down an AsyncTask.

Creating a background services

Create a class RSSPullService and extends IntentService to create component IntentService



          public class RSSPullService extends IntentService {
    @Override
    protected void onHandleIntent(Intent workIntent) {
        // Gets data from the incoming Intent
        String dataString = workIntent.getDataString();
        ...
        // Do work here, based on the contents of dataString
        ...
    }
}
       
 

Define IntentService with application Manifest


Create a background work request and send it to IntentService

Create a new, explicit Intent for the IntentService called RSSPullService.

mServiceIntent = new Intent(getActivity(), RSSPullService.class);
mServiceIntent.setData(Uri.parse(dataUrl));

Call startService()

// Starts the IntentService
getActivity().startService(mServiceIntent);

Report Status from an IntentService See Google Android Article 

Download Source


Monday, 22 December 2014

Fun time : Five reason to hate beautiful android

Everyone around me having android in their hand

Off course everyone around me have android in their hand and i am fed up of being one of them. I want to look different so i am switching to costly iPhone which gonna change my status among people around. Even its easy to be identify, people generally say "Ohh you'r talking about guy with iPhone".

Android is open source and vulnerable to security of personal data

Even i don't care if somebody try to explain me that android is no less secure than windows and ios. I am smart enough to secure my personal data even i don't have any. I like apple annoying pop up for asking permission again and again.

I don't like customization of home screen in android

Come on we are using smartphone so why to allow user to customize home screen ? I like rigid way of iPhone and windows. I don't like change at all so i love iOS and windows


Being a philanthropist i always support sinking ship

I was big fan of android when Google launch it. But when i see iOS start dying and windows crawling, i almost cry that day. Then i decided no matter what android do, i will support windows and iOS. Even i continue forced my all relative to use expensive iOS untill they kick on my ass.

I hate android for no reason

OK ! I am free to do what i want, so do i hate damn beautiful android and its huge app market.
Note : This article is written for fun. Keep this in mind


Android One is coming to Bangladesh, Nepal, and Sri Lanka soon

As part of Google to reach out maximum number of user,  Google collaborated with manufacturer to manufacture low budget devices. Their outcome named android one. Android one succeed in India and now Google plan to launch it in Bangladesh, Nepal, and Sri Lanka Which will cover 200 million user.
Google blog says In these countries — with a combined population of over 200 million people — a wide range of manufacturers and network partners such as Banglalink will begin to sell Android One smartphones. In addition to Micromax, Karbonn and Spice, Bangladesh’s own Symphony will launch their first Android One phone with the Symphony Roar A50. All these devices will give people a high quality mobile experience for an affordable price, running stock-Android with updates from Google.
Android One in India's neighbors

Android one is strong phone and cost Approx $100. Upgrading to newer o.s will work like nexus and Google will send update of latest android to Android one.

Saturday, 20 December 2014

Switching to CyanogenMod : An extended version of Google android mobile operating system

CyanogenMod  is enhanced open source firmware distribution for smartphones and tablet computers based on the Android mobile operating system. It offers features and options not found in the official firmware distributed by vendors of these devices.

Big Question : Should we start switching to CyanogenMod ?


CyanogenMod  is just extended version of android with lot of feature supporting, originally they are not supported in android. CyanogenMod  is fair deal for tech enthusiast.


There are some feature which exclusively supported in CyanogenMod 


  • Theming support
  • FLAC audio codec support
  • A large access point list
  • Open VPN list - OpenVPN is an open-source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities. It uses a custom security protocol[2] that utilizes SSL/TLS for key exchange
  • Enhance reboot menu 
  • USB tethering, CPU over locking and other performance and many others.

Lot of coding enthusiast and volunteer had work hard to make Google Android code transform into CyanogenMod. Still they are working collectively to benefit most smartphones. They have a good bug tracking and improvment system. So lets try this with Micromax's Yu Yureka

Tuesday, 9 December 2014

Micromax canvas selfie launched officially, A phone with great specification

Micromax canvas selfie goes official in press event with tennis star like Sania Mirza,  Ana ivanovic. Micromax canvas selfie will directly compete to HTC Desire Eye. canvas selfie loaded with 13 MP front and rear facing camera.

Micromax Canvas Selfie loaded with 1.7GHz octa-core CPU, 2GB of RAM, and 16GB of expandable memory. The device’s display is a 4.7” 720p unit covered by Gorilla Glass 3. The smartphone will run with Android 4.4 KitKat and is powered by a 2,300mAh battery. Micromax has biggest share of smartphone in Indian market and directly competing with Chinese manufacture like oppo and Xiaomi.

Micromax Canvas Selfie Launch event

According to GSM arena, Micromax canvas selfie will launch in India in second week of January in two colors - Angelic White and Mystic Blue. Price of canvas selfie is not uncovered yet.
Keep a comment if you have plan to go with Micromax canvas selfie.

Key features of Canvas Selfie


  • 13MP rear & front cameras with
  • flash & Sony Sensor
  • Inbuilt Beauty Tools in the
  • Camera App like Eye
  • Enhancement, Face Slimming,
  • Skin Smoothening, Teeth
  • Whitening, Remove Oil and Fade
  • Dark Circles, Make-up
  • 4.7-inch HD IPS display
  • Color depth of 16.7 million
  • Corning Gorilla Glass 3
  • 2300 mAh battery
  • 1.7 GHz Tru-octacore processor
  • Android KitKat 4.4
  • Dual SIM; Common slot for
  • memory card and nano SIM card
  • 2GB RAM; 16GB ROM
  • Expandable memory of up to32GB
  • Available in Mystic Blue and
  • Angelic White colors
  •  Faux leather back finish


Sunday, 7 December 2014

Message and Request to Reader of This Blog

I have been blogging since 3 year and writing on this site by arranging my time. Sometime even i had help people personally too if i had time. And you guys give me so much respect in return. Usually my purpose was to benefit all struggling android beginner but as time passes i realize if you are not getting any benefit in terms of livelihood then its hard to continue.


Today i making one appeal to my dear reader, if this blog had ever help you in past or will help you in future, then please help me by

  • Download and share my apps
  • Shop through my affiliate program Flipkart for Indian user and Amazon for non Indian User. Banner are attached to site
  • Keep visiting so that my motivation of writing will always be high 


Friday, 5 December 2014

WRITE_EXTERNAL_STORAGE permision limit to primary memory acess : Weirdest update of Android KitKat 4.4

Post Address Issue -


  • WRITE_EXTERNAL_STORAGE  doesn't work with Android KitKat 4.4
  • Android KitKat 4.4 doesn't allowing writing to secondary storage
  • Error accessing the SD card on Android KitKat (4.4.x)

I had gone through Weirdest  issue recently, My app suddenly got bad reviews as  app is not working with Android KitKat 4.4 and above. I dig out and find problem, My android application was not able to read from android secondry memory storage (i.e called Sdcard also.). Android KitKat 4.4 support WRITE_EXTERNAL_STORAGE  in certain manner now.

Interesting point for KitKat is that writing to secondary external storage (such as SD memory card) is prohibited, except of app's specific directory, which is deleted during app uninstall.Only solution to this problem is to get your phone rooted.

Google Android cleary says


The WRITE_EXTERNAL_STORAGE permission must only grant write access to the primary external storage on a device. Apps must not be allowed to write to secondary external storage devices, except in their package-specific directories as allowed by synthesized permissions. Restricting writes in this way ensures the system can clean up files when applications are uninstalled.

If your phone is rooted you will have access to /system/etc/security/permissions.xml . media_rw is clearly missing here

<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
<group gid="sdcard_r" />
<group gid="sdcard_rw" />
<group gid="media_rw" />
</permission>

still its not clear why Google android KitKat 4.4 has logic behind this Weirdest . See Reported BUG to Android 4.4 does not allowing writing to secondary storage.

Thursday, 4 December 2014

Moto G first generation will get Android Lollipop update soon From Motorola Offcial Blog

Motorola had confirm upgrade of Android Lollipop to Moto G first generation. And it should start rolling out very soon according to Motorola news. Motorola other phone Moto G second generation and Moto X are already start getting upgrade to Android L. Android Lollipop is latest version launch by Google Android.

GSM Arena stated
Well, it seems they won't have to wait too long. Motorola has updated the Motorola Update Services app on the first generation Moto G. If you check the change log for the app, it simply says 'This update is necessary to enable a future upgrade of your device to Android 5.0, Lollipop.
Its seems that User will start getting upgrade in mid December.
                  

Motorola is very quick in providing latest update to its user. Motorola promise Android Lollipop upgrade to below devices.

  •     Moto X (1st Gen. & 2nd Gen.)
  •     Moto G (1st Gen. & 2nd Gen.)
  •     Moto G with 4G LTE
  •     Moto E
  •     Droid Ultra, Droid Maxx, and Droid Mini


Tuesday, 2 December 2014

WebView Scroll Vertically : WebView scroll in one direction after zoom in android

Android WebView allow to load HTML content. Recently i was facing issue regarding zoom of WebView. What my requirement was, for scroll WebView content vertically regardless of its zoom level. Simply i want to stop horizontal scroll of webview.
I came across meta tag ViewPort and it did a lot of help with some attribute of WebSettings dynamically.

  • Wrap WebView inside ScrollView
  • Meta Tag viewport : Attach this meta tag immediately after <head>

<meta name="viewport" content="width=device-width,height=device-height,target-densityDpi=device-dpi,user-scalable=yes,initial-scale=0.5, maximum-scale=2, minimum-scale=0.5" />

If you don't have control on HTML content, then read HTML content in one string and then append above tag and then write to file again or use with webview's method loadwithBaseURL

StringBuilder mBuilder = new StringBuilder(mBuffer.toString().replace("<head>",
"<head><meta name=\"viewport\" content=\"width=device-width,height=device-height,target-densityDpi=device-dpi,user-scalable=yes,initial-scale=0.5, maximum-scale=2, minimum-scale=0.5\" />"));

mBuffer is the HTML string. you can change WebView's scale according to requirement

  • Attribute need to set dynamically are 

view.getSettings().setLoadWithOverviewMode(true);
view.getSettings().setUseWideViewPort(true);
view.setWebChromeClient(webChromeClient);
view.getSettings().setBuiltInZoomControls(true);
view.getSettings().setSupportZoom(true);

where view is reference of WebView.

Achieve Through this Article 

  •  Content will fit to new line to scroll WebView only vertically
  •  Fit content to initial scale using Meta Viewport
  • Content will not go more than WebView width




Monday, 1 December 2014

Samsung to launch Tizen O.S : Why South Korean giant Samsung choose India?

Samsung is going to launch Tizen new mobile o.s in India on new sub-$100 smartphone. They had a plan to launch it in Russia but they scrap the plan. Samsung mostly device are running android o.s platform. Android is responsible for their recent success over Apple. They thoroughly enjoyed selling their overprice devices but cheap compare to Apple iPhone. But now they are coming up with their own Tizen operating System.

Why they choose specifically India?


India had a huge market which is not still explored totally so they had huge opportunity to reach out million of customer with their Tizen mobile operating. Its kind of beta phase and they don't want to cost their prime customer in USA and Europe with developing O.S. Indian are pretty much price sensitive and they will buy Tizen loaded device with $100 (INR 6000). In recent survey, its stated that Indian smart phone user prefer low end and cheap device and they never complain about quality of product. And Samsung choose rightly this point and in the mean time they will try to improve Tizen before they go to USA or Europe.

There is section in India which has capability of purchase high end phone and those will not give a shit to $100 Tizen phone.



Its will be good to see weather Samsung can survive without Android !

Wednesday, 19 November 2014

Promotion Article : Cheap and best calling from USA to India by suing Telcan Calling card.

“Call More Often and Stay Connected sans any Hassles” has been the ideology of Telcan for years that has earned the coveted pre-paid calling and VoIP service provider a wide customer base in more than

200 countries worldwide. Touted as the most powerful, comprehensive and economical way to make

calls to or from US, Canada and India respectively, we relentlessly strive to deliver enhanced and smart

calling solutions to our clients.

Telcan.com  offer the cheapest calling rates in the industry. Leveraging on latest technology, we deliver

call rates as low as $0.011 per minute. What’s more, with each account you get 8 distinct ways to make

calls to India, US and Canada. The SMS facility is free to let you stay connected with your loved ones on

the go. Plus being bi-directional in nature, you can make calls to and from to respective desired

countries using a single card. Revel in the holistic calling experience Telcan provides with smart features

such as Toll Free, Local Access, VoIP Apps, Access using Skype and MagicJack and even One Touch

Calling to name a few.  We maintain our own customer service and routing staff in the U.S. and India on

a 24 hour basis. The staff comprises of proficient technicians and professionals from telecom industry

itself. Live support available via web chat, phone call or email is always available.

The strong call routing network in A to Z carrier routes in several countries allows Telcan to maintain

minimal call connecting lead time and call quality. The cards offered are universally compatible with a

wide range of internet enabled devices. The service provider has developed several indigenous mobile

apps to let you access these cards via Andriod&iOS based phones, Skype and Gmail. These apps can be

downloaded online from leading software portals for free by the registered users. The registration

process is easy.

For more information visit : https://www.telcan.com/

Wednesday, 15 October 2014

Android Imagine, Invent and Make : Android 5.0 Lollipop is launched

Rumors about launched date of Android 5.0 Lollipop is over now. It had officially launched today by Google Blog. Google latest version of android already created a lot of buzz. Now Android 5.0 Lollipop has come with over 5,000 new APIs for developers. Which is obviously a giant work done by Google developers and contributor.

Android 5.0 Lollipop

Google Android 5.0 Lollipop is officially launched today and from tomorrow Android sdk 5.0 can downloaded by developers to development purpose.

Google Android stated clearly Android is reaching in our Room, Car and even on out wrist too. This made for all mobile operating system had showed tremendous growth.

Google Says “As you switch from one screen to another, the experience should feel the same. So Lollipop has a consistent design across devices—an approach we call Material Design. Now content responds to your touch, or even your voice, in more intuitive ways, and transitions between tasks are more fluid.

Android 5.0 Lollipop Features


Lollipop gives more control over phone, User can now adjust your settings so that only certain people and notifications can get through, for example, when you’re out to dinner or in the middle of an important meeting. And when an important notification does come through, you can see it directly from the lockscreen

  • New Battery Saver which extends battery life up-to 90 minutes.

  • See estimated time before your phone get charged

  • Now in 68+ languages
  • Android TV

          Support for living room devices

  • Better Media API and support
  • As same in all launched Better, faster and smoother :)



Thursday, 9 October 2014

HTC Desire EYE Best SELFIE camera phone with 13 MP

HTC Desire Eye

The phone is unique; a much larger than usual front-facing camera is positioned above the screen and it gets a dedicated dual-LED flash and a microphone. It's getting the same treatment as the back camera, which has a dual-LED flash and a microphone too. There's another microphone on the bottom of the device for a total of three mics used for better audio through noise cancellation.
Both cameras can record 1080p@30fps video. The one on the back has an f/2.0 aperture and a 28mm lens, while the one on the front has a wider 20mm lens but a smaller f/2.2 aperture.

It features a 5.2 inch screen with 1080p resolution, runs on Snapdragon 801 chipset, 2GB RAM and runs Android 4.4 with latest Sense software and two camera centric apps; Eye Experience and the new Zoe. The phone also boasts LTE connectivity, dual-band Wi-Fi a/b/g/n/ac, Bluetooth 4.0 with aptX, NFC and a microUSB port. It got 16GB internal storage, expandable microSD card slots upto 128GB and a 2,400 mAh battery.

HTC EYE Experience will roll out to the following models (full feature list to be confirmed at roll-out): HTC One (M7), HTC One (M8), HTC One (E8), HTC One mini, HTC One mini 2, HTC One Remix, HTC One Max, HTC Desire 612, and HTC Desire 816 in the coming months.

Best thing About HTC Desire Eye which is brand new invention

13 MP, autofocus, dual-LED (dual tone) flash, HDR

13 MP, 4128 x 3096 pixels, autofocus, dual-LED (dual tone) flash




Monday, 29 September 2014

Motorola Google Nexus 6 Launch : A big no to 5.9 Inch android phone

LG  collaboration wit Google provide us a good nexus 5, which is still amazing phone. It has been a long time around til the day nexus 5 was launched. But still price of android nexus 5 is not down like Samsung devices.
Now there are rumor about nexus 6(Nexus X) will be a Motorola. Motorola has taken android market by storm with their two device Moto X and Moto G.

 According to AnTuTu, the handset will be running Android 5 L, have a 5.9in QHD screen, Qualcomm Snapdragon 805 SoC processor and 3GB of RAM. Which is surely quite impressive. 


The key point of Nexus 6 is its bulky size of 5.9 inch, which obviously a Phablet. Google may have decide to try their hand in Phablet. Nexus is undoubtedly favorite phone among android lover because of its latest update, Google flagship and handy design. I never see a Nexus lagging anywhere.

 Is Google mistaking by competing with Samsung note series ?



  •  I talk to many existing android user who have a thought about Nexus 6, And they say Big no to this. And main cause was its bulky size. Samsung had targeted  corporate user via Note series which commendable. Samsung has fragment user base , but Nexus doesn't. 


  •  Second, Samsung had worked hard to customize and optimize android O.S to fit requirement of bigger Phablet. So performance are surely good. I doubt Goolge and Motorola can spend such amount of time on this.


 Release date of Nexus 6


 Google Nexus 6 is expected to launch around same time(October) when Nexus 5 was launched. This will launch with Android L version of android.

Wednesday, 28 May 2014

PHILIPS W6610 5300 mAh Battery ! A smart phone with best battery is launched

Smart phone had many thing which drain battery and leaving those thing behind does not give feel of smart phone. Running apps all the time (like Whatsapp, Facebook and weather services), HD display and many more cause battery to die. So anticipation of user were battery to invent to next level and PHILIPS did it. It launched PHILIPSW6610 with 5300 mAh battery which best till date.
Bigger battery strength make phone thicker compare to its competitor but you can enjoy Standby time: 1604 hrs (WCDMA+GSM) and Talk time: 33 hrs (WCDMA). PHILIPSW66 run on android version Jelly Bean (4.2) and PHILIPS does not reveal about up gradation weather they are going to update to latest version or not. It will cost around Rs.20,262.00 or $340 (Approx).



PHILIPSW66 launched with 1 GB RAM, 1.3 GHZ quad core processor. The smartphone packs a 5-inch display with qHD resolution (960 x 540) 4GB of internal memory, microSD support, dual SIM support and Android 4.2 Jelly Bean.

Wednesday, 14 May 2014

Must purchase Moto E, Low end phone is going to be game changer


Motorola has come back strongly with Moto G 8 GB and 16 GB variant. This took middle end phone market by storm specially India and developing country. Motorola has been sold millions of device include both version Moto G and Moto X. They have been super hit in terms of performance and price. Motorola received positive review from user.

Now Motorola comes with best low end phone Moto E running on android latest version 4.4 Kitkat on price of just 6999 INR (Approx $ 100) which incredible. There are lot of phone present in Indian and Chinese market with this price, But what Motorola is providing with this price make me speechless.

Moto E price 6999 INR running on android latest version with 4.3 inch screen HD, 1 GB Ram and 1.2 GHz MSM8x10 Dual Core Processor

Why should you purchase it?

  • Dual Standby SIM (GSM + GSM)
  • Android v4.4 (KitKat) OS
  • Wi-Fi Enabled
  • 1.2 GHz MSM8x10 Dual Core Processor
  • 4.3-inch Touchscreen
  • 5 MP rear camera
  • Android OS, v4.4.2 (KitKat)
  • 540*960 HD resolution

Note : Moto E available on flipkart.com from today

Final note : Even if you are not interested in low end just purchase it for fun.

Customizing Support Android Action bar Tab : android.support.v7.app.ActionBar and Action Bar

Action Bar is integral part of android design guidelines. Action Bar API was intruduces in android version 3.0 and above but few months ago Google launch backward compatibility support for ActionBar with Support v7 library. Here see Action Bar Tab integration with Fragment

I have gone through some customization of Support Action Bar android Action Bar. So here I am sharing those piece of source code which help me to beautify Android Action Bar

Action Bar Background Color -


   <!-- ActionBar styles -->  
   <style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">  
     <item name="android:background">@color/name</item>  
     <!-- Support library compatibility -->  
     <item name="background">@color/name</item>  
   </style>  


Action Bar Title Text Customization


   <!-- ActionBar styles -->  
   <style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">  
     <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>  
     <!-- Support library compatibility -->  
     <item name="titleTextStyle">@style/MyActionBarTitleText</item>  
   </style>  
   <!-- ActionBar title text -->  
   <style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">  
     <item name="android:textColor">@color/tabText</item>  
     <!-- The textColor property is backward compatible with the Support Library -->  
   </style>  

Action Bar Tab Customization


  • Action Bar Tab Text Customization

   <!-- ActionBar tabs text -->  
   <style name="MyActionBarTabText" parent="@style/Widget.AppCompat.ActionBar.TabText">  
     <item name="android:textColor">@color/tabText</item>  
     <!-- The textColor property is backward compatible with the Support Library -->  
   </style>  

  • Action Bar Tab's View and Selector Customization - Action bar Tab View can be customize. You can use your own custom view or set custom selector align Tab Text, and Change padding of Tab Text inside action bar Tab

   <!-- ActionBar tabs styles -->  
   <style name="MyActionBarTabs" parent="@style/Widget.AppCompat.ActionBar.TabView">  
     <!-- tab indicator -->  
     <item name="android:background">@drawable/tab_selector</item>  
     <!-- Support library compatibility -->  
     <item name="background">@drawable/tab_selector</item>  
     <item name="android:paddingLeft">0dp</item>  
     <item name="android:paddingRight">0dp</item>  
     <item name="android:paddingTop">0dp</item>  
     <item name="android:paddingBottom">0dp</item>  
   </style>  

Here how you create Tab Selector XML to apply all effect (i.e Selected,Pressed,Unselected) – All Images should be placed rightly in drawables


 <?xml version="1.0" encoding="utf-8"?>  
 <selector xmlns:android="http://schemas.android.com/apk/res/android">  
   <item android:drawable="@android:color/transparent" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>  
   <item android:drawable="@drawable/tab_selected_example" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>  
 -   <!-- Focused states -->  
   <item android:drawable="@drawable/tab_unselected_focused_example" android:state_focused="true" android:state_pressed="false" android:state_selected="false"/>  
   <item android:drawable="@drawable/tab_selected_focused_example" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>  
 -   <!-- Pressed -->  
 -   <!-- Non focused states -->  
   <item android:drawable="@drawable/tab_unselected_pressed_example" android:state_focused="false" android:state_pressed="true" android:state_selected="false"/>  
   <item android:drawable="@drawable/tab_selected_pressed_example" android:state_focused="false" android:state_pressed="true" android:state_selected="true"/>  
 -   <!-- Focused states -->  
   <item android:drawable="@drawable/tab_unselected_pressed_example" android:state_focused="true" android:state_pressed="true" android:state_selected="false"/>  
   <item android:drawable="@drawable/tab_selected_pressed_example" android:state_focused="true" android:state_pressed="true" android:state_selected="true"/>  
 </selector>  

Now give all theme Reference to main theme and use this theme for any activity in Android manifest 


   <style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">  
     <item name="android:actionBarStyle">@style/MyActionBar</item>  
     <!-- Support library compatibility -->  
     <item name="actionBarStyle">@style/MyActionBar</item>  
     <item name="android:actionBarStyle">@style/MyActionBar</item>  
     <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>  
     <item name="android:actionMenuTextColor">@android:color/background_light</item>  
     <!-- Support library compatibility -->  
     <item name="actionBarStyle">@style/MyActionBar</item>  
     <item name="actionBarTabTextStyle">@style/MyActionBarTabText</item>  
     <item name="actionMenuTextColor">@color/tabText</item>  
     <item name="android:actionBarTabStyle">@style/MyActionBarTabs</item>  
     <!-- Support library compatibility -->  
     <item name="actionBarTabStyle">@style/MyActionBarTabs</item>  
   </style>  



Tuesday, 18 February 2014

Gujarati language font support android example with source code

I had seen many developer struggling to support Guajarati language with android phone in their own application. Application like news hunt support Guajarati so that’s means its surely possible.

  • See very simple code to support Guajarati language inside android application. 

           TextView mtxt = (TextView) findViewById(R.id.action_settings); 

           Typeface face1 = Typeface.createFromAsset(getAssets(), 

                     "Lohit-Gujarati.ttf"); 

           mtxt.setTypeface(face1); 

           mtxt.setText("પૂર્વ વડાપ્રધાન રાજીવ ગાંધીની હત્યા કરનારા 3 આરોપીઓની ફાંસીની સજા સુપ્રિમ કોર્ટે ઉમ્રકેદમાં ફેરવી નાંખી છે.આમ રાજીવગાંધીના" + 

                     "3 હત્યારાઓને હવે ફાંસીની સજા નહી થાય.સુપ્રીમ કોર્ટમાં 3 જજોની બેન્ચે આજે આ ચુકાદો આ"); 




Download source Code

Monday, 17 February 2014

Android FTP client tutorial with example of uploading, downloading and authentication with FTP server

FTP protocol is standard network protocol for transferring file. It works on peer to peer base network. In recent days I had written few articles about file transfer protocol and comparison among them to choose best. After research, research shows that FTP outperformed everything in android. So I decide to write about FTP client implementation. This tutorial will teach you
  • Android FTP client Authentication - How to connect with FTP server?
  • Android FTP client Download - How to download a file from FTP server?
  • Android FTP client Upload -How to upload a file to FTP server?

Basic requirement for this tutorial is one simple FTP server setup at your desktop. You can use file-Zilla or IIS server for this requirement.

  • Android FTP client authentication and listing file from FTP server

      /**  
       *   
       * @param ip  
       * @param userName  
       * @param pass  
       */  
      public void connnectingwithFTP(String ip, String userName, String pass) {  
           boolean status = false;  
           try {  
                FTPClient mFtpClient = new FTPClient();  
                mFtpClient.setConnectTimeout(10 * 1000);  
                mFtpClient.connect(InetAddress.getByName(ip));  
                status = mFtpClient.login(userName, pass);  
                Log.e("isFTPConnected", String.valueOf(status));  
                if (FTPReply.isPositiveCompletion(mFtpClient.getReplyCode())) {  
                     mFtpClient.setFileType(FTP.ASCII_FILE_TYPE);  
                     mFtpClient.enterLocalPassiveMode();  
                     FTPFile[] mFileArray = mFtpClient.listFiles();  
                     Log.e("Size", String.valueOf(mFileArray.length));  
                }  
           } catch (SocketException e) {  
                e.printStackTrace();  
           } catch (UnknownHostException e) {  
                e.printStackTrace();  
           } catch (IOException e) {  
                e.printStackTrace();  
           }  
      }  

  • Android FTP client download a file from FTP server – you can browse through directory saved on FTP server and can download desired file or directory. I just write code here for downloading a single file and writing it to sdcard/phone memory.

      /**  
       * @param ftpClient FTPclient object  
       * @param remoteFilePath  FTP server file path  
       * @param downloadFile   local file path where you want to save after download  
       * @return status of downloaded file  
       */  
      public boolean downloadSingleFile(FTPClient ftpClient,  
                String remoteFilePath, File downloadFile) {  
           File parentDir = downloadFile.getParentFile();  
           if (!parentDir.exists())  
                parentDir.mkdir();  
           OutputStream outputStream = null;  
           try {  
                outputStream = new BufferedOutputStream(new FileOutputStream(  
                          downloadFile));  
                ftpClient.setFileType(FTP.BINARY_FILE_TYPE);  
                return ftpClient.retrieveFile(remoteFilePath, outputStream);  
           } catch (Exception ex) {  
                ex.printStackTrace();  
           } finally {  
                if (outputStream != null) {  
                     try {  
                          outputStream.close();  
                     } catch (IOException e) {  
                          e.printStackTrace();  
                     }  
                }  
           }  
           return false;  
      }  

For browsing through directory see this Browsing Nested Directory

  • Android FTP client uploading a file to FTP server – You can upload a file to server with object of FTPClient at desired path which you need to define.

      /**  
       *   
       * @param ftpClient FTPclient object  
       * @param downloadFile local file which need to be uploaded.  
       */  
      public void uploadFile(FTPClient ftpClient, File downloadFile,String serverfilePath) {  
           try {  
                FileInputStream srcFileStream = new FileInputStream(downloadFile);  
                boolean status = ftpClient.storeFile("remote ftp path",  
                          srcFileStream);  
                Log.e("Status", String.valueOf(status));  
                srcFileStream.close();  
           } catch (Exception e) {  
                e.printStackTrace();  
           }  
      }  

Download Jar  

 

Note : Keep all methods inside background thread (i.e Asynchronous Task, Service)

 See Sambha file sharing client for android

Wednesday, 12 February 2014

Best file transfer protocol : Which to use among SMB, Socket (TCP/UDP) and FTP?



I had gone through the requirement of file transfer using peer to peer in a same network. I tried the case of server and client too because I had not any issue to run server script (in case of Socket Connection). Main purpose was to attain maximum transfer speed of data. So I tried with three most popular protocols for file transfers which are –
  • SMB – Server Message Protocols known also as sambha file sharing
  • Socket- Work on the base of client server concept
  • FTP- File transfer protocol

Comparison for performance –


Phone
Protocol
Data
Distance
Time
Max Speed
XOLO
Socket
1.3 GB
5 Meter
16 Min
1.3 MB/S
XOLO
SMB
0.7 GB
5 Meter
25 Min
0.5 MB/S
XOLO
FTP
1.3 GB
5 Meter
14 Min
1.6 MB/S

Notable Point about file transfer protocols –

  • Socket – Server scripting required for file transfer. This connection cannot be named as peer to peer
  • SMB – No scripting required for file transfer. It can read any file structure of peer computer
  • FTP FileZilla can do the trick for file transfer. No Server script required

Term and Condition – These all testing has been done between an android and a low configuration desktop (Windows 7). Both were connected to one dedicated wifi local network



Android News and source code