Skip to main content

Android Best Practices for User input, Background jobs, Performance, Security and privacy - Android

There are some practices that you can follow while developing android application. These are suggested by the android itself and they keep on improving with respect to time. These best practices include interaction design features , performance , security and privacy , compatibility , testing , distributing and monetizing tips. They are narrowed down and are listed as below.

Best Practices Android - GoforExam.inBest Practices - User input

Every text field is intented for a differnet job. For example, some textfields are for text and some are for numbers. If it is for numbers then it is better to dispaly the numeric keypad when that textfield is focused. Its syntax is.

<EditText 
          android:id="@+id/phone" 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content" 
          android:inputType="phone" />

Other then that if your field is for password , then it must show a password hint , so that the user can easily remember the password. It can be achieved as.

<EditText 
         android:id="@+id/password" 
         android:hint="@string/password_hint" 
         android:inputType="textPassword" />

Best Practices - Background jobs

There are certain jobs in an application that are running in an application background. Their job might be to fetch some thing from the internet , playing music e.t.c. It is recommended that the long awaiting tasks should not be done in the UI thread and rather in the background by services or AsyncTask.

ASYNCTASK VS SERVICES. 
Both are used for doing background tasks , but the service is not affected by most user inteface life cycle events, so it continues to run in circumstances that would shut down an AsyncTask.

Best Practices - Performance 
Best Practices


Your application peformance should be upto the mark. But it should perform differently not on the front end , but on the back end when it the device is connected to a power source or charging. Charging could be of from USB and from wire cable.
When your device is charging itself , it is recommended to update your application settings if any, such as maximizing your refresh rate whenver the device is connected. It can be done as this.

IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); 
Intent batteryStatus = context.registerReceiver(null, ifilter); 
// Are we charging / charged? Full or charging. 
int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1); 
// How are we charging? From AC or USB. 
int chargePlug = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);

Best Practices - Security and privacy

It is very important that your application should be secure and not only the application , but the user data and the application data should also be secured. The security can be increased by the following factors.
1. Use internal storage rather then external for storing applications files
2. Use content providers wherever possible
3. Use SSl when connecting to the web
4. Use appropriate permissions for accessing different functionalists of device

Comments

Popular posts from this blog

CIVIL SERVICES' (I.A.S.) EXAMINATION

The Union Public Service Commission (U.P.S.C.)  conducts Civil Services' Examination once a year in two stages. The Preliminary Examination (Objective Type) for selection of candidates for the Main Examination is held in the month of May. The Civil Services Main Examination  is held in the months of October/November. Blank application forms and other particulars are published in the Employment News, generally in the month of December. The last date for the submission of applications to the Secretary, Union Public Service Commission, Dholpur House, Shahjahan Road, NewDelhi-11001 1 is usually the last week of January of the year of examination. The Combined Civil Services Examination is conducted for Recruitment to the following Services/Posts: 1. Indian Administrative Service. 2. Indian Foreign Service. 3. Indian Police Service. 4. Indian P & T Accounts & Finance Service, Group 'A'. 5. Indian Audit and Accounts Service, Group 'A'. 6. Indian Customs and Centr

Predict the output or error(s) for the following:

1 . void main(){ int const * p=5; printf("%d",++(*p)); } Answer: Compiler error: Cannot modify a constant value. Explanation: p is a pointer to a "constant integer". But we tried tochange the value of the "constant integer". 2. main() {  char s[ ]="man"; int i;  for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[i],*(s+i),*(i+s),i[s]); } Answer: mmmm aaaa nnnn Explanation: s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i]. 3 . main(){  float me = 1.1;  double you = 1.1;  if(me==you) printf("I love U"); else printf("I hate U"); } Answer: I hate U Explanation : For floating point numbers (float, double, long double)

AGRICULTURAL SCIENTIST RECRUITMENT BOARD

Agricultural Research Service National   Eligibility  Test/ Senior Research Fellowship Examination  The Agricultural Scientists Recruitment Board (ASRB)  holds a Competitive Examination for recruiting Scientists of the ARS in the pay scale of Rs. 8,000-13,500 in the ICAR Institutes, combined with National Eligibility Test (NET) for recruitment of Lecturers and Assistant Professors by the State Agricultural Universities (SAUS) and for award of ICAR Senior Research Fellowships. The selected candidates for Agricultural Research Service must serve in the institutes to which they are posted until they find appointment for higher positions through selection at other institutes. (i) Candidates successful in ARS are appointed as Scientists in the Indian Council of Agricultural Research in the pay scale of Rs. 8,000-13,500. (ii) Candidates clearing the National Eligibility Test are recommended to various State Agricultural Universities who will consider them for appointment as Lecturers or A