" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi

Seeding Database(Rhom) in RhoMobile-Rhodes

Posted on November 24th, 2015 by Soutom Dhara

Sometimes we need to load some data to internal DB at the time of initializing/Starting of the application.   In below mentioned code I have defined how to insert one admin user’s record to User table. For this we have to write our code ‘initialize‘ method of AppApplication Class. This appApplication class is available in […]

How to use local storage feature in PhoneGap application

Posted on November 23rd, 2015 by Sourabha Sahoo

If you want to store a small amount of data locally in the mobile device then local storage feature is a good solution. It acts same as the cookies in web application and  stores the data as key value pair. The data will persists even after we close the application. It will be removed only […]

Set volume of music playing in cross-platform app using Corona

Posted on November 23rd, 2015 by Raju Mahato

Introduction : Using Corona SDK we can play music stream and also set the volume of the music. Description : Lets make a page where we will play music and will set the volume for that. CODE BLOCK : main.lua — Code to hide the status bar display.setStatusBar( display.HiddenStatusBar ) — Give background color to […]

Getting Geolocation in Android device using PhoneGap.

Posted on November 23rd, 2015 by Sourabha Sahoo

You can find the Geolocation of your Android device using Phonegap by getting the latitude and longitude of the current position of the device. Following steps illustrate how to use Phonegap to get device current Geolocation. 1.Include the Phonegap/Cordova javascript file inside your html page. 2.Add the eventlistner to load the function when device gets […]

Getting Images from Gallery and SD card in Smartphones using PhoneGap

Posted on November 23rd, 2015 by Sourabha Sahoo

If you want to get the images from device gallery or SD card, Phonegap can help you to do it by using the following method. 1.Include the Phonegap/Cordova javascript file inside your html page. 2.Create a function to get the images from specified source like Gallery or SD card. function getImage() { navigator.camera.getPicture(onSuccess, onFailure, { […]

Getting Contact List With Contact Information From Android Devices using PhoneGap

Posted on November 23rd, 2015 by Sourabha Sahoo

You can easily find the contact list with the information like phone number, contact name, email address and birthday from Android devices by simply using PhoneGap. Following steps expalin how to use Phonegap to get the contact information. 1.Include the Phonegap/Cordova javascript file inside your html page. 2.Add the eventlistner to load the function when […]

Sending text messages from Android device using PhoneGap

Posted on November 23rd, 2015 by Sourabha Sahoo

While working on how to send SMS from smartphone using PhoneGap, I found the plugin which is really very usefull & easy to integrate with Phonegap application. Given below is the example and steps to use the plugin & send message from Android device. Targreted OS: Android Technology: PhoneGap 1. First of all you need […]

Get custom URL when PhoneGap application is launched from custom URL

Posted on November 23rd, 2015 by Sourabha Sahoo

Introduction: If you are opening your Android app using custom URL scheme and passing some parameter in the custom URL, then after opening the app you may need to get the parameter. So here is the solution for it. Description: Suppose you are opening your application from other application e.g. email and you need some […]

Showing Splash Screen At The Start Of Android PhoneGap Application

Posted on November 23rd, 2015 by Sourabha Sahoo

If you want to disaplay a splash screen at the beginning of Phonegap based Android application you need to put splash screen image(splash.png) inside res\drawable-hdpi,  res\drawable-mdpi,  res\drawable-idpi which can be located inside your project directory. The splash screen image size should be different for different size of Android devices. For large screens size (hpdi) image […]

How to disable the scrollbars in PhoneGap Android application.

Posted on November 23rd, 2015 by Sourabha Sahoo

You can hide the Vertical and Horizontal scrollbar in PhoneGap application in Android by adding following lines in Activity.java file super.appView.setVerticalScrollBarEnabled(false); super.appView.setHorizontalScrollBarEnabled(false); After adding these lines Activity.java will look like this package com.mindfire.HelloWorld; import android.os.Bundle; import org.apache.cordova.*; public class HelloWorldActivity extends DroidGap { /** Called when the activity is first created. */ @Override public void […]

How to Justify Text in Android TextView

Posted on November 23rd, 2015 by Arti Gupta

Android does not supports full justification of text in a textview. It does not have in-built option for it. However, you can justify text in android using WebView. The webview: Android does not supports full justification of text in a textview. It does not have in-built option for it. However, you can justify text in […]

Remove scrolling of html content in WebView in Titanium.

Posted on November 23rd, 2015 by Raju Mahato

We are generally using WebView to display our html content to our apps. For iPhone app, if we add any html content to a webView it works fine as we expected, but for android the UI get distorted little bit. Horizontal and vertical scrollbar appears to that view. To fix that all those issue use […]

File downloading using titanium.

Posted on November 23rd, 2015 by Raju Mahato

Code to download files using our cross platform iPhone/Android app in Titanium is described below. Code Block : //Url of the file that need to be downloaded var downloadingFileUrl = “Url of the file that need to be downloaded” //File path where downloaded file will be saved var fileSavingPath = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,”file_Path”); //Define the http client […]

Click Event Issue For Android In Titanium

Posted on November 23rd, 2015 by Lopamudra Joshi

 In Titanium in case of android, if we define “touchstart” and “click” events for a button, the click event will not work untill we defined the “touchend” event for that button. But for iPhone the click event does not depends on “touchend” event. So the code to accomplish the job in both OS the without […]

Display Android Application only in Portrait mode

Posted on November 23rd, 2015 by Sourabha Sahoo

You can make your Android application to be displayed only in portrait mode using Titanium by making following changes. 1.Create directory platform/android in your project directory. 2.Copy AndroidManifest.xml file from build/android directory and paste it inside platform/android that you have already created. 3.Edit the AndroidManifest.xml file inside platform/android directory by adding android:screenOrientation=”portrait” in all activity […]

Adding Map view to an application IPhone.

Posted on November 23rd, 2015 by Lopamudra Joshi

Google Maps is the most common platform implementation and the one both Android and the iPhone platforms utilize. Here we will implement a mapView by providing lattitude and longitude of a particular region. Let us create a view  //create our mapview var mapview = Titanium.Map.createView({ top: 110, height: 350, mapType: Titanium.Map.STANDARD_TYPE, region: {latitude: 26.00, longitude:94.00, […]

Facebook integration on cross-platform mobile application

Posted on November 23rd, 2015 by Raju Mahato

Facebook integration on cross-platform mobile app using Titanium. The following code is tested with iPhone,iPod and Android. Let say we have a view. Onclick of that view a window will appear to make post on Facebook. Ti.Facebook.appid = ‘Your_Application_Id’; // We will get this ID, when we will regiter this app on facebook Ti.Facebook.permissions = […]

Use Images From The Device Gallery In A IPhone/Android Application Using Titanium

Posted on November 23rd, 2015 by Raju Mahato

Sometime we need to extract images from device gallery in our application. Process to accomplish this using titanium for iPhone/Android devices are described below. Let say we have a window with a button to open gallery from device. //Define the current window var myWin = Titanium.UI.currentWindow; //Define the button to activate camera var openGalleryBtn = […]

Getting Screen Height And Width Using Titanium In Android/iOS Devices

Posted on November 23rd, 2015 by Sourabha Sahoo

You might need to find the screen width and height of Andriod/iOS devices to make your application compatible in different sizes of screen. So by using the following lines of code you can fetch the screen height and width of Android/iOS devices with Titanium. //fetch the height of the screen var screenHeight = Ti.Platform.displayCaps.platformHeight; //fetch […]

Moving to current one after closing the previous window in android

Posted on November 23rd, 2015 by Raju Mahato

Sometime we need to perform some job while opening a new window in our application. For the time lets say we will show an alert message informing which page we are moving. The code to do so is described below. Code Block : //Define the current window var employeeWin= Ti.UI.currentWindow; //Define a button var changeWinBtn […]

Removing autofocus from textBox and auto keyboard pop-up on page load

Posted on November 23rd, 2015 by Lopamudra Joshi

While window load text box in Android automatically gets focussed as a result the Android Soft Key Board Pops Up. To Remove this automatic Popping Up of key Board use the following Code. Note : Text Field is mentioned as Pg.searchBar where the Window name is Pg.win Pg.win = Titanium.UI.currentWindow; //searchBar creation Pg.titleText = Ti.UI.createTextField({ […]

Check internet connection on device using Titanium

Posted on November 23rd, 2015 by Raju Mahato

Some applications require active internet connection to run on our smart devices. So here is a simple way to check connectivity and its status using Titanium described below with an example. Code Block : //Define the current window var currentWin = Ti.UI.currentWindow; //Define a Button var getDetailsBtn = Ti.UI.createButton({ width : 100 //width of the […]

Play Sound File in Cross Platform Application Using Titanium

Posted on November 23rd, 2015 by Raju Mahato

At times there are requirements in an application where we need to play sound with some action in background. There is a way to do that in cross platform application using Titanium, the following block of code accomplishes it. //Define current window Var currentWin = Ti.UI.currentWindow; //Define a button var playSoundBtn = Ti.UI.createButton({ width : 100, […]

Set control position across different resolutions for android in Titanium

Posted on November 23rd, 2015 by Raju Mahato

Generally in Appcelerator Titanium we are using numbers in pixel to set the position (left/right/top/bottom) of a control in a window for an app that will run on different platform (IOS/Android). But there is a problem with this process. Android has devices with different resolution and in that case the control position gets altered due […]

Alternating Color of Each Row in TableView Using Titanium

Posted on November 23rd, 2015 by Raju Mahato

If we need to show data in row format, usually we use TableView in Titanium to build crossplatform application where we some time give alternate row color to each row. Here is code snippet to describing the scenario. Code Block : //Define the current window var currentWin = Ti.UI.currentWindow; //Array variable having row data var […]

Get Number of Rows of a TableView in Crossplatform App Using Titanium

Posted on November 23rd, 2015 by Raju Mahato

Its very common for a developer to deal with table and its rows and to know about the number of rows present in the table. I have often faced problems related to this. Finally I got the solution which is described below. CODE BLOCK : //Define current window var currentWin = Ti.UI.currentWindow; //Define table view var dataTable = […]

Install application exclusively on SD card in Android using Titanium

Posted on November 23rd, 2015 by Raju Mahato

Application built using Titanium is generally large in size. So sometime it is advisible to install an app to the SD card added with the device. Titanium has ability to instruct the app installer to install te app to the SD card. Here is a way to do that. In order to that we need […]

Use Slider As A Progress Bar In Crossplatform App Using Titanium

Posted on November 23rd, 2015 by Raju Mahato

Here is a trick to use slider as progressbar described below. CODE BLOCK : //Define current window var currentWin = Ti.UI.currentWindow; //Define a button to strat the progress var stratBtn = Ti.UI.createButton({ width : 200, height : 50, title : ‘Strat Progress’, top : 300 }); //Button added to window currentWin.add(stratBtn); //Define a slider var […]

Identifying File Type When Downloading It In Titanium

Posted on November 23rd, 2015 by Raju Mahato

While working with file downloading I came across a situation  where I didn’t know the file type that I am going to download but I have to take some action depending on the downloaded file type. So here is the quick tip to know the file type before saving it to a directory after downloading. […]

Install application exclusively on SD card in Android using Titanium

Posted on November 23rd, 2015 by Raju Mahato

Application build using Titanium is generally large in size. So sometime it is advisible to install an app to the SD card added with the device. Titanium has ability to instruc the app installer to install te app to the SD card. So here is a way to do that. In order to that we […]

Toast Notification In Android Application Using Titanium

Posted on November 23rd, 2015 by Raju Mahato

Introduction :    Its very common in web application, where when we takes our cursor over a link or image, generally we can see a tooltip describing about the control or tells about the control. So can we do something like that on our mobile app….? Description :   Generally in web application, when we […]

Creating persistent shared preference to save activity state

Posted on November 23rd, 2015 by Prateek Aggarwal

Whenever activity is in paused state, we create shared preference fileto save currrent state of activity for example: onPause() { SharedPreferences.Editor editor = getSharedPreferences(file_name,MODE).edit();                      or SharedPreferences.Editor editor = getPreferences(MODE).edit(); // editing data stored in default preference file //store data that we want to persist using edit.putString(TAG,VALUE),edit.putInt(TAG,VALUE) } Now , whenever activity is restarted restore […]

Remove ListView selection when ListView is scrolled

Posted on November 23rd, 2015 by Shubhankar Mazumdar

When ListView is scrolled the ListView and its items tends to appear to be selected. To prevent this call setCacheColorHint(0) on the ListView object variable. For example ListView listview=new ListView(this); listview.setCacheColorHint(0)

Animation on Switching between activities

Posted on November 23rd, 2015 by Arti Gupta

This tip features how to change Android’s default animation when switching between Activities. The code to change the animation between two Activities is very simple: just call the overridePendingTransition() from the current Activity, after starting a new Intent. This method is available from Android version 2.0 (API level 5), and it takes two parameters, that are used to define […]

Setting the MaxLength of EditText at run time in Andriod

Posted on November 23rd, 2015 by Noor Alam

If we want to limit the character input in an EditText , EditText in XML layout gives us android:maxLength to do this. But in java codes you might wonder why there isn’t any setMaxLength(int length) function. The reason behind this is that when you want to restrict the EditText to accept certain value, you have […]

Weight Attribute with Linear Layout

Posted on November 23rd, 2015 by Ashish Sharma

To distribute screen width between two views in a ratio of 2 : 3 , we can specify weight as below: <LinearLayout android:layout_height=”match_parent” android:layout_width=”match_parent” android:weightSum=”5″> <LinearLayout android:id=”@+id/layout1″ android:layout_width=”0dp” android:layout_height=”wrap_content” android:layout_weight=”2″ /> <LinearLayout android:id=”@+id/layout2″ android:layout_width=”0dp” android:layout_height=”wrap_content” android:layout_weight=”3″ /> <LinearLayout> Using the above XML, layout1 will have 2/5 of total parent width while layout2 will have 3/5 […]

How to add straight line of specific width,height and color in layouts using TextField | Android

Posted on November 23rd, 2015 by Noor Alam

If you want to add strait lines in your layout you can use TextView in xml file as follows: (1) In drawable folder add a xml file e.g. divider.xml <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <stroke android:gravity=”top” android:color=”#000000″ /> </shape> (2) Now use above xml file as the background of the TextView as follows <TextView android:layout_width=”fill_parent” […]

Avoid paste of the clipboard content in an EditText in Android

Posted on November 23rd, 2015 by Ravi Kumar

Ocurrence : This problem appears whenever we make a long press on an EDITTEXT in a particular  layout.  Solution: This could be avoided by using setOnLongClickListener on the EDITTEXT (or  implementing interface  OnLongClickListener). EditText mEditText=(EditText) findViewById(R.id.cEditText); mEditText.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View v) { return true; } }); The return value of  OnLongClick() method will […]

How to make widgets like imageview, button etc. present in listview it…

Posted on November 23rd, 2015 by Ravi Kumar

Whenever we include  these clickable items like imageview , button in a listitem as child, it does loses it’s clickable property. To retain that clickable property, set clicklistener on these widgets(children for a listview item) with in the adapter class where these views are rendered. In Adapter Class’s getView method do: public void getView(int position, View convertView, ViewGroup parent) { ViewHolder […]

Add CustomAttribute from a CustomView in XML

Posted on November 23rd, 2015 by Rupesh Kumar

Android provides facility to create our custom view and use it’s custom attribute in XML. For this, first we create a custom view with some custom attribute and then inflate it in XML. class MyCustomView extends View{  /* variable to hold custom attribute*/    String heading; /*now initialize object that use for setting the Custom Attribute .Like -Paint,Matrix,Color etc..*/ […]

Handling Event Consumption for a View in ListView

Posted on November 23rd, 2015 by Prateek Aggarwal

f we want to perform similar function like onClick by onTouch for a view then we have to monitor two action ACTION_DOWN and ACTION_UP As you can see in example here: public boolean onTouch(View v,MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: userIDTag = (String)v.getTag(); break; case MotionEvent.ACTION_UP: then based on the userIDTag that we have […]

Keeping the image at the bottom of the screen in Android

Posted on November 23rd, 2015 by Noor Alam

I faced a problem in image placement at the bottom of the screen. In the following layout when the focus comes to the played@ EditText and the keypad. The outline of the layout is as follows . <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” … > <ScrollView android:layout_width=”1”..> <LinearLayout ……> <LinearLayout….. > <TextView …/> <EditText …/> </LinearLayout> […]

Handling Activity And It’s Context Lifecycle.

Posted on November 23rd, 2015 by Deepak Sharma

Context in android is always used to get application specific resources (drawables,string values …. etc) and calling some application level operations such asContext in android is always used to get application specific resources (drawables,string values …. etc) and calling some application level operations such asstarting Android components (components such as Activity,Service,broadcast Receiver,Content Provider …. etc). […]

Touch events interception between CustomViewGroup(Layout) and its child in Android

Posted on November 23rd, 2015 by Ravi Kumar

This tip can be useful when we want some touch events handled by  CustomViewGroup(Layout) and others handled by its child. For the first, we write CustomViewGroup class extending ViewGroup and in this class we handle touch events by overriding the dispatchTouchEvent() method of ViewGroup. We write code for touch events handled by CustomViewGroup in dispatchTouchEvent() method and must return super.dispatchTouchEvent() for handling touch events of […]

How to create a rounded cornered view ( via xml ) for Android.

Posted on November 23rd, 2015 by Divya Arora

While creating Android Apps,at times we face a need to create a view with rounded corners. This can be done by creating a XML file in the res/drawable folder whose content would be like:   <?xml version=”1.0″ encoding=”UTF-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle”> <gradient android:startColor=”#D2E0E2″ android:endColor=”#D2E0E2″/> <corners android:bottomRightRadius=”4dp” android:bottomLeftRadius=”4dp” android:topLeftRadius=”4dp” android:topRightRadius=”4dp”/> </shape>   he gradient attribute will specify […]

How to get touch event of a Spinner without the popup in Android

Posted on November 23rd, 2015 by Noor Alam

When we touch a spinner, a popup list appear which shows the options to choose from. But suppose there is a scenario where there are two spinners, one for selecting state and second for selecting school from that state .At start there is no school in the school spinner. When we select a state from […]

Best way to detect fling gesture on ListView item

Posted on November 23rd, 2015 by Shubhankar Mazumdar

The ListView has a “OnScrollListener” listener which which can be used to detect fling gesture The “OnScrollListener” interface has following methods: onScrollStateChanged(AbsListView view,int scrollState) where view = holds the reference of ListView scrollState= it can be SCROLL_STATE_FLING or SCROLL_STATE_TOUCH_SCROLL or SCROLL_STATE_IDLE.   If the user flings on list item then the above method’s scrollSate will […]

Reusing XML layouts in Android

Posted on November 23rd, 2015 by Noor Alam

Sometimes we need to put same header and/or footer on every screen of our application. Rewriting the same code in each xml file will consume much more time and reduce the efficiency of the application. Also reusing code will make the code clean, easier to understand and hence easy to debug. Android provide us the […]

Keeping the data in ListView with interactive items while scrolling in Android

Posted on November 23rd, 2015 by Noor Alam

Some times we need a list view with interactive items like EditText , Radio Buttons ,Check Box etc on its rows. But When the no of items in the list view is large and we have to scroll the list to navigate up and down one problem arises.Suppose we are at the top of the […]

Optimization using Android Lint tool

Posted on November 23rd, 2015 by Ashish Sharma

A lint tool is provided as part of ADT ver 16 and can be used to detect following issues. 1) Missing and unused translations 2) problems related to layout (ex duplicate ids, unsupported parameters) 3) finds unused resources which are not referenced in the project. 4) Icon problems like missing densities, duplicate icons, wrong sizes, […]

Using Surface View for Android

Posted on November 23rd, 2015 by Ashish Sharma

Surface View Tutorial This tuturial guides in using surface view at a very basic level . The code presented in this tutorial creates a simple view with a image using a surface view instead of conventianal View object. Create New Project & Activity Lets create a new android project using ecilpse. Lets name it SurfaceExample […]

Solution for “Bad token” exception in while using custom Dialog.

Posted on November 23rd, 2015 by Arti Gupta

If you are creating a custom Dialog for Android, and using “getApplicationContext()” to pass the application context in the dialog, then most likely you would have faced a Force Close with this exception showing up in logcat. Uncaught handler: thread main exiting due to uncaught exception android.view.WindowManager$BadTokenException: Unable to add window — token null is […]

Copying larger databases from asset in Android

Posted on November 23rd, 2015 by Deepak Sharma

Copying large database from assets in Android Why to copy database : Sometimes to make database and populating data. in it may take heavy time like 5 minutes or more, which is a lot so in such cases we can make our database in seperate application and copy it in Project ,which is done quickly. […]

How to disable selection of selected items in a ListView

Posted on November 23rd, 2015 by Shubhankar Mazumdar

If you wish that on pressing a particular list items , the list item does not gets selected for example if you wish that last two items in list view can never be selected , its implementation is as follows: The data shown in ListView is determined by its adapter and all adapter are  child […]

Uploading Images In Android

Posted on November 23rd, 2015 by Bhaskar Pande

In Android when you are required to upload an image it must be decoded into a bitmap….it is here we often run into trouble because the size of the resulting bitmap often results in an memory overflow exception. To prevent this you can adopt the following two steps of preprocessing the image….. Step 1. compressing […]

Removing theme background to prevent over drawing wraning

Posted on November 23rd, 2015 by Ashish Sharma

If one or several layout completly covers the parent view/ default view, then the default background is not visible to the user. That means the default background draw is not usefull and can be avoided. One way to acheive this optimisation is to create a custom theme where in we set the background as null. […]

Change Layout Properties Of Views On Orientation Change

Posted on November 23rd, 2015 by Shubhankar Mazumdar

f you wish some views to have different layout properties in landscape and portrait when the orientation changes  or if you wish few views to have different layout properties when activity inflating the layout containing the views opens in particular orientation, following are the steps:  if you wish some views to have different layout properties […]

Custom View for designing layout through ‘XML Based Layout’ in Android

Posted on November 23rd, 2015 by Ravi Kumar

If we want to use of custom view through XML based layout ,then we must override constructor  View(Context context, AttributeSet attrs) in custom view. This is only constructor  called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied […]

Avoiding out of memory Exception in Android

Posted on November 23rd, 2015 by Ashish Sharma

Below are some steps which can help in  avoiding out of memory exceptions while using bitmap 1. We should unbind the drawables; associated with layouts . 2.We should convert our hashmaps to&nbsp WeakHashmaps.Doing so will have the effect that the hashmap memory would get relaesed when system runs low on memory 3. We can override onLowMemory() method in […]

Accessing resources like color from non activity classes

Posted on November 23rd, 2015 by Ashish Sharma

Setting the rerources like color using resource file does not work in non activity class. We need to access the resource folder and then we can set the color. Eg: TextView tv = (TextView)findViewById(R.id.text1); Incorrect: tv.setTextColor(R.color.color_name); Correct Syntex: tv.setTextColor(getResources().getColor(R.colo.color_name));  

Use Content provider to load html file from SDCARD to Android Webview

Posted on November 23rd, 2015 by Arti Gupta

Many times we need to load an html file from device sdcard to webview. For example, you normally load a url in webview when network is available, but in case network is not available currentl, you need to load latest offline html file which was previously cached on device sdcard. Now, in this case, you cannot load […]

Setting keyboard key background image.

Posted on November 23rd, 2015 by Noor Alam

First create a state list drawable as follows   key_selector.xml: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_checkable=”true” android:state_pressed=”false” android:state_checked=”false” android:drawable=”@drawable/key_background_checkable” /> <item android:state_checkable=”true” android:state_pressed=”true” android:state_checked=”false” android:drawable=”@drawable/key_background_checkable_pressed” /> <item android:state_checkable=”true” android:state_checked=”true” android:state_pressed=”false” android:drawable=”@drawable/key_background_checked”/> <item android:state_checkable=”true” android:state_checked=”true” android:state_pressed=”true” android:drawable=”@drawable/key_background_checked_pressed”/> <item android:state_checkable=”false” android:state_checked=”false” android:state_pressed=”true” android:drawable=”@drawable/key_background_pressed”/> <item android:state_checkable=”false” android:state_checked=”false” android:state_pressed=”false” android:drawable=”@drawable/key_background”/> </selector> and in the xml file which extends […]

How to disable the scrollbars in PhoneGap Android application.

Posted on November 23rd, 2015 by Sourabha Sahoo

You can hide the Vertical and Horizontal scrollbar in PhoneGap application in Android by adding following lines in Activity.java file  super.appView.setVerticalScrollBarEnabled(false);  super.appView.setHorizontalScrollBarEnabled(false); After adding these lines Activity.java will look like this package com.mindfire.HelloWorld;   import android.os.Bundle; import org.apache.cordova.*;   public class HelloWorldActivity extends DroidGap {     /** Called when the activity is first created. […]

Displaying App in Full Screen Mode in Android

Posted on November 23rd, 2015 by Ashis Kumar

In the AndroidManifest.xml file, add the following code to your Activity. android:theme=”@android:style/Theme.NoTitleBar.Fullscreen” This will make the activity to run in the Full Screen Mode ( no title bar & no notification bar )

Restart Android Application So That When The Application Quits All Running Activities And Tasks Are Closed Automatically

Posted on November 23rd, 2015 by Shubhankar Mazumdar

Let’s say that your main activity is SplashScreen.class and you wish to restart your application from activity, say Restart.class. You can call the following statements in the Restart.class, to terminate the application and start the main activity again Intent iIntent = new Intent(this, SplashScreen.class); startActivity(iIntent); <code to clear your data> android.os.Process.killProcess(android.os.Process.myPid());

Showing Splash Screen At The Start Of Android PhoneGap Application

Posted on November 23rd, 2015 by Sourabha Sahoo

If you want to disaplay a splash screen at the beginning of Phonegap based Android application you need to put splash screen image(splash.png) inside res\drawable-hdpi,  res\drawable-mdpi,  res\drawable-idpi which can be located inside your project directory. The splash screen image size should be different for different size of Android devices. For large screens size (hpdi) image […]

Using Device Accelerometer to shake graphics/view object

Posted on November 23rd, 2015 by Arti Gupta

Accelerometer is a hardware sensor used to detect a shake movement in device. This tip is about using accelerometer to move a “drawable image” on screen. To access device sensor, we need to use “SensorManager” class. We will need to implement “SensorEventListener” listner to listen accelerometer movement and move the images accordingly. When a movement […]

NEAR FIELD COMMUNICATION in Android

Posted on November 23rd, 2015 by Bhaskar Pande

This tip investigates some of the ways in which the Android API may be used to implement NFC (Near Field Communication) “Near field communication is a set of standards for smart phones and similar devices to establish radio communication with each other by touching them together or bringing them into close proximity, usually no more […]

Converting speech to text in Android using PhoneGap

Posted on November 23rd, 2015 by Sourabha Sahoo

While working with voice to text conversion in Android I came across SpeechRecognizer plugin for PhoneGap. So bellow are the steps to integrate this plugin with Android using PhoneGap. 1. Download the SpeechRecognizer plugin from github by using this url.     https://github.com/phonegap/phonegap-plugins/tree/master/Android/SpeechRecognizer     You will find two folder as v1.8.0 and v2.0.0. So pick the v2.0.0 as we are […]

Hiding Soft Keyboard When Focus Is On Text Box | Android For Rhomobile

Posted on November 23rd, 2015 by Ashis Kumar

Problem: While developing application using Rhomobile for Android platform, i came across a situation where,  when a user focuses on text fields, soft keyboard pops up, but it overlaps the input field so we can’t see what we are entering. The page also doesn’t scroll so that we can’t manually scroll the page to get […]

AutoComplete Textview using Xamarin Android

Posted on November 23rd, 2015 by Anup Samantaray

The code snippet below creates an AutoComplete textview Step -1 Add the below code in the Main.axml(design screen)   <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:minWidth=”25px” android:minHeight=”25px”> <AutoCompleteTextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:id=”@+id/autoCompleteCity” /> </LinearLayout>   Step-2 Overide the OnCreate method of Activity and set the MainLauncher attribute to true in your own activity. So that the application […]

Extracting Bitmap from the ViewGroup in Android

Posted on November 23rd, 2015 by Ankit Khare

We can’t extract the bitmap from a ViewGroup in onCreate() of an Activity , so in order to extract bitmap we use the onAttachToWindow()(which is called when our when the window attached to this activity is attached to the window manager) and call our method in this overrided method to  extract and return the bitmap. […]

Simple Implementation To Customize action_mode_close Button From ActionMode Layout

Posted on November 23rd, 2015 by Ravi Kumar

We will address the above though the following example. Note : We will be modifying the predefined layout for action_mode_close_button .Main Task : Removing Done text from ActionModeClose button layout. Resolution 1 :  One way to hide it is to access the resource id of the view that we want to customize using Resources api […]

Horizontal Scroll View With Custom Width

Posted on November 23rd, 2015 by SAHIL GUPTA

We might need to implement  a requirement where a large horizontal scroll view is required. Usually it is required when reports or transactions have to be displayed. Since data in reports transactions can extend horizontally and vertically. We need a horizontal scroll view with large width or modifiable widths. Following code (a snippet from layout […]

Disable multi touch in the android app

Posted on November 23rd, 2015 by Trayambak Mishra

Today I came across a issue where simultaneous touch on more than one button makes app misbehave as the api calls were made on both buttons. In order to resolve the issue I came across a solution. Though there are other ways too but I felt this one is the simplest and most efficient. If […]

To add straight line of desired width,height and color in layouts using TextField in Android

Posted on November 23rd, 2015 by Noor Alam

If you want to add strait lines in your layout you can use TextView in xml file as follows: (1) In drawable folder add a XML file e.g. divider.xml <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <stroke android:gravity=”top” android:color=”#000000″ /> </shape> (2) Now use above XML file as the background of the TextView as follows <TextView android:layout_width=”fill_parent” […]

Making A Smooth Scroll View For Android & iOS in HTML

Posted on November 23rd, 2015 by Ashis Kumar

Problem: Scroll view achieved using CSS overflow scroll property for android & ios devices are never that smooth as they are in the native way. Solution: So, to achieve that smoothness, we need to use CSS positioning property as well as css3 -webkit-overflow-scrolling property. let’s see how we can achieve this. For iOs & Android […]