Saturday, March 21, 2015

Debug your devices Wirelessly without Root

It's easy to connect and debug your apps in android devices wirelessly without Root.

All you need is,
 1. Android Device
 2. Mac / PC with Android SDK
 3. USB Cable

USB Cable ??? Just for the first time for a session.

Make sure your android device and the system is on same wifi network.

Next,

1. Locate your <sdk>/platform-tools
2. Go to Terminal / Command Prompt
3. Navigate to the location identified in step 1.
4. Connect your device using USB. (Make Sure USB Debugging is turned 'on')
5. Now it will be listed when you execute "adb devices".
6. Turn on tcpip feature.
      adb tcpip <ip address>:5555
7. Type the command,
      adb connect <ip address>
8. Once Step 7 is done, the device is connected through wifi. Check it by ensuring it is listed under "adb devices".
9. Remove the cable and verify your connection wirelessly.

You will be able to see your logs, execute adb commands etc.,

To reconnect using usb.
1. Execute,
     adb kill-server
2. Connect your device and execute, 
     adb usb - start adb

Now the device is connected via USB.


References

Thursday, March 27, 2014

Signing and Verifying APKs

Signing applications with a key has become an essential part in the process for mobile app developers. It's like a signature for the app.

 To know how to sign the applications, visit the android developer reference here.

Now let us see how to verify whether the app ( android build.. APK) is signed or not and with what key.

  As mentioned already in one of my posts that describes how to install APK programmatically, an APK file is a kind of jar file.

 Go to command prompt and type the following and replace <path> and <app_name> accordingly.
   jarsigner -verify <path>/<app_name>.apk

 command. If you see "jar verified" message, it means it is a signed one.

 To know more about the key details, type the below
   jarsigner -verify -verbose -certs <path>/<app_name>.apk

  If you see "CN=Android Debug", this means the .apk was signed with the debug key generated by the Android SDK(means it is unsigned), else you will find something for CN.



References

Thursday, January 2, 2014

Happy New Year & Android in 2014

Wish you all a Happy & Prosperous New Year !!

Hope you may be excited to know what might be happening in the next year. Interested in Future Predictions, Check out my App in Google Play.

Now let's look what we can expect in Android. 4GB RAMs, 64 bit Processors for mobiles, wearable gadgets and many more interesting things..

Currently there are many manufacturers for Android Smartphones unlike iPhones. Here is a list of expectations/forecast for the new year -

1. Samsung's next mobile in the pipeline may be Galaxy S5 or Note 3. It is observed to have produced a 4GB RAM for mobiles. (My MacBook Pro Mid 2012 has 4GB RAM). Technically it is 50% faster than existing phones and consumes 40% less power. Read More..

2. The future mobiles may have finger print and swipe sensor to verify identity & unlock.  Sweden`s Fingerprint hopes to sell its own touch sensors to other big mobile phone makers like Samsung, LG Electronics and Huawei. Read More..

3. Intel has big Android ambitions for 2014. The chipmaker's points of focus for the year ahead include 64-bit processing power and more tablets. Read More..

4. Google to team up with Audi for Android in cars. Read More..

5. Android 4.4 KitKat 2014 Rollouts for many SmartPhones including 5 HTC Phones, LG G2 And G Pad, 8 From Motorola, 9 Sony Xperia And 20 Samsung Galaxy. Read More..

6. Wearable gadgets,flexible displays down the line. Read More..

7. Nokia rumoured to be working on Android Phone. Nokia Normandy. Read More..

Above is only a short list.. Other Suggestions are welcome.


Sunday, December 29, 2013

Android Application - Develop,Build & Run Without Eclipse or any IDEs

We are generally using Eclipse IDE and ADT Plugin for developing Android applications. I too am doing the same in my mac. But few days back, something struck me, Android is an open-platform, and as such, we can create,build and test a java program without an IDE, simply using text editor,jdk and command line. On its core, programs for android are written in Java only. So why can't we try out doing the same for Android. Googled out, to surprise, its there in developer forum site itself. My bad, 2 years in android development, but in a hurry have never noticed it.

There are no hard steps to take off. Its very simple. We can create,run/debug as well get release version of apk using only command line and text editor along with Android SDK and Java JDK. No IDEs required !!

Before Getting Started
1. Download the Android SDK, Java JDK and Ant.

2. Add the android sdk, java jdk and Ant installation folder to the path variable. Please refer my blog on how to add path variables in mac.

3. Go to terminal and type the below,
        android list target
    to know the list of available android apis in the sdk. Download relevant apis using sdk manager. Note down the target id which you want to set as minsdk. To open sdk manager from command promt, type android

Creating a Project
1. Open terminal and type the below code,
   android create project --target 3 --name MyAppWithoutEclipse --path /Users/badrionapple/Documents/workshop/MyAppWithoutEclipse --activity MainActivity --package com.terminal.app
 Here --target     ->  Min SDK
          --name     ->  Project Name
          --path       ->  Physical location in the disk
          --activity  ->  Name of Main Activity
          --package ->  Package name for the app.
On successful completion, you will be able to find the full project structure being created in the location specified in path argument.

2. Edit manifest file, layouts, activity etc., as per your requirement.

Adding Libraries,Updating Projects
Please refer the link here.

Building and Running
Android projects are built using Ant tools. You will be able to find "Ant" folder in <android-sdk>/tools/.
1.Go to the root folder of your application and type the below in terminal,
    ant debug
  Compilation and build path errors will be listed, if any. On successful build, Now you have your apk signed in debug mode. You may, in addition face bufferoverflowexception, please refer here to solve it.
2. Opening emulator is easy. To know emulators i.e avds available, type android list avd in terminal. Managing AVDs from command line.
3. Type the below code, to start your avd, in terminal,
     emulator -avd <your-avd-name>
    [Note : You must have added both <android-sdk>/tools as well as <android-sdk>/platform-tools to path variable]
4. Verify whether avd is successfully started in terminal using below command,
     adb devices
5. Once your avd is listed, type the below to run your code,
     adb install bin/<your-Project-name.apk>

Distributing APKs
Please refer here.

Constraints that you may face while using command line,
  •  Unable to set breakpoint and debug your code.
  •  No Drag & Drop UI in xml for layouts, resources as well for manifest.
  •  Need to Set up everything manually for avds.
  •  Debugging is quite unfriendly(finding compile errors etc., and correcting it).
  •  No Ctrl+Shift+T or R to search classes,resources or search keywords in full workspace and other facilities that comes up with Eclipse or any IDE.


References
http://www.anddev.org/novice-tutorials-f8/developing-android-apps-without-eclipse-t13912.html
http://developer.android.com/tools/projects/projects-cmdline.html
http://developer.android.com/tools/building/building-cmdline.html
http://developer.android.com/tools/devices/managing-avds-cmdline.html



Tuesday, December 24, 2013

Handling ListView in Android

Android APIs provides many views i.e controls to present the information and interact with user. ListView is one among them. However for the sake of utilising the memory efficiently, Android system reuses the views in certain components.

ListView is a list of items to be displayed to the user from which he/she may choose an item. The item can either be a simple text or combination of image and text or still more complex layouts. When writing custom adapters to fit in data for such complex items in list, there would have been need to override the getView().

Issue
Now coming to the point, As said, android reuses the views. In case,there are more number of items in the list than that can be displayed to the user in the screen. In such cases, Listview is scrollable. Now when populating the data to such lists, you will get parameter in getView that identifies the position of the item that is inflated.

Say the screen can display 5 items. Populating data from either list or array using the position parameter will populate correctly for the first five items. From the next item onwards, getView() will be called only with the position parameter ranging from 0-4. Consequently, you will be able to see only the first five data in your data list getting repeated in the listview.


Solving the issue, 
Add these lines to the listview in xml,
       android:layout_height="0dp"
       android:layout_weight="1"

This solves the issue.

References :
http://lucasr.org/2012/04/05/performance-tips-for-androids-listview/
http://stackoverflow.com/questions/2618272/custom-listview-adapter-getview-method-being-called-multiple-times-and-in-no-co/2639159#2639159
http://stackoverflow.com/questions/10120119/how-does-the-getview-method-work-when-creating-your-own-custom-adapter

Friday, December 20, 2013

Kitkat in emulator

KitKat -  name of Chocolate Bar from Nestle?

Also the latest version of Android OS V4.4 from Google.

While everyone were expecting "Key Lime Pie" as the title for next release, It was a nice Strategy from Google to consider the name, its kind of win-win for both. Nestle gets popularity as well as Google. There was even a contest with KitKat chocolates wrapped up in special wrappers with Android Logo in it. There was promo-code and you could text it to a number and you had chance to win exciting gifts from Google like Playstore credits or Nexus devices.

The first mobile to come with kitkat is Nexus 5,

To know about the detailed set of features, please refer here.

Now lets get into the picture. I downloaded Kitkat apis for my android sdk and was trying to start an emulator running kitkat. Tried with all the alternatives changing the display settings, turning on/off use host gpu feature for emulator. Nothing worked, only black screen, not even android logo appeared. There were also buzzes in web, that for Mac, intel image is yet to be released and that default ARM image takes long time to load. I waited atleast 30 mins, even an hour, but in vain.

With advice from one of my colleague, since my mac was also having 4GB Ram, I increased the Ram size of the emulator to 2048MB, after which, all of a surprise android logo appeared and emulator got started.

PFB the settings which worked for me in my Mac,

























Buying an Android Device

There are many brands in android phone market. There are devices in all cost ranges. Which one to choose ? Read further.

To set things, I am not going to suggest any popular model phones, buy this, that etc., I am just going to give you hints and insight for buying a smartphone.

Deciding on the smartphone can depend on the following factors,
1. Need.
2. Budget.
3. Like for Brands.

NEED
 Question yourself, why do you need a smartphone.
   1. Are you a developer considering of testing your apps ?
   2. Are you a tech savvy person, buy the latest trend devices and test it ?
   3. Are you a gadget geek ?
   4. Are you going to use the phone for your work , need big screen for viewing maps,shares,GPS etc., need a phone or tablet ?
   5. All my friends / Everybody has, let me also have one.
   6. What are you going to do with your phone ? - just call/sms or more than that.. email, browsing, chat, social networking, hear songs, movies..

BUDGET
 If you are considering budget phones, go for local brands, but try to make the best brand as possible. Read the brands section. There are many shopping/comparison sites in the web which you can google out to find an idea on the price ranges and you can then go to a showroom and buy one.

BRANDS
Popular Brands : Samsung, LG, Sony, HTC
Popular but local : Micromax, Karbonn, Cellkon, Intex etc.,

Best things about each brand,

Samsung - Hardware, always latest trend in market
LG - Hardware
Sony - UI, richness of use
HTC - UI
Micromax - Affordable costs for Asian Market.

I personally own HTC Explorer A310e, I really love its UI, design, fonts, colors etc.,

My advice would be to avoid local brands as much possible.

Where can I buy from ?
  Nowadays there are many options through which one can buy a device. It can be done
   1. Via Shopping Sites(online)
   2. Via Showroom
   3. Via Manufaturer Sites(online)

Buying online as well from showroom has its own advantages and disadvantages as well.

In online, you can have access to devices available worldwide and you may have some devices which is not currently available in market, but was once available, second hand mobiles etc., Offers may also be available. But you may need to put in a lot of effort to find out the genuinity of the seller and the brand he is marketing through online. You will not be able to touch the device.

In showroom, you can get a full touch and feel of the device. You can bargain. You will have many offers, like data plan, memory card etc., However brands may be restricted.

Tips
1. Keep branded phones as preferable.
2. Fix your budget and need.
3. Compare and choose one among the various models.
4. Talk to the users/friends who has the mobile that you have chosen and get their experience.
5. Make sure you get warranty and bill details while buying.

Most important thing to consider in a phone irrespective of brand/budget is Battery Life. Make sure it has sufficient battery life atleast for a day, because today's smartphones last one day in average. There are even apps available in market that retrieves the information of apps consuming more power which can be turned off safely.

Other most notable ones are screen resolution,memory card, camera quality,bluetooth,wi-fi. Apart from these, NFC,GPS etc., other stuffs are fancy items in the shelf.