Thursday, July 21, 2011

Usefull adb commands



1) START ADB

      C:\Users\ganesh.v\.android>adb

2)KILL THE ADB SERVER

       C:\Users\ganesh.v\.android>adb kill server

3) sTART THE ADB SERVER

       C:\Users\ganesh.v\.android>adb start server

4)ADB LOGGCAT

      C:\Users\ganesh.v\.android>adb logcat

5) OPEN LINUX SHELL

      C:\Users\ganesh.v\.android>adb shell

6)START ACTIVITY

      C:\Users\ganesh.v\.android>adb shell am start -n com.gani.vt/com.gani.vt.Main

7) RE INSTALL APPLICATION
   use  the application path to install in to the device or emulator through the system.

     C:\Users\ganesh.v\.android>adb install -r D:\projects\AsyncTaskData\bin\AsyncTaskData.apk

8)INSTALL APPLICATION

     C:\Users\ganesh.v\.android>adb install D:\projects\AsyncTaskData\bin\AsyncTaskData.apk

9)Install application with multiple devicesattached.

adb -s device-id install apk name


10)  UN INSTALL THE APPLICATION
    use package structure to uninstall the application through the device

   C:\Users\ganesh.v\.android>adb uninstall com.gani.vt

11) Instrumentation test commands for robotum
adb shell am instrument -w com.votary.navDistance/android.test.InstrumentationTestRunner

hardware sensors in Android


Hardware sensors are present in almost all the modern mobile phone devices. Different types of sensors like accelerometer sensor, magnetic field sensor, orientation sensor, proximity sensor, etc. are present in these devices. Sensors that are present vary from device to device.
In Android different types of sensors are supported. SensorManagerclass is used to access these sensors. Sensor Manager is a system service running in Android. We get an instance of this service by callingContext.getSystemService() method with SENSOR_MANAGER as the argument. Android supports different types of sensors, some of them are:
Sensor.TYPE_ACCELEROMETER - accelerometer sensor
Sensor.TYPE_GYROSCOPE - gyroscope sensor
Sensor.TYPE_LIGHT - light sensor
Sensor.TYPE_MAGNETIC_FIELD - magnetic field sensor
Sensor.TYPE_ORIENTATION - orientation sensor
Sensor.TYPE_PRESSURE - pressure sensor
Sensor.TYPE_PROXIMITY - proximity sensor
Sensor.TYPE_TEMPERATURE - temperature sensor
Not all these will present in the target device, so before start using a particular type of sensor, we need to check whether the desired sensor is present in the device or not. We can check the presence using eitherSensorManager.getDefaultSensor() orServiceManager.getSensorList(). Both methods accept sensor type parameter as an argument. In case ofServiceManager.getSensorList() method we can pass the Sensor. TYPE_ALL to get all the sensors present in the system. Once we confirm the desired sensor is present in the device, we can start getting the event updates from the sensor usingSensorManager.registerListener() method. This method accepts oneSensorEventListener callback interface. This is the interface that SensorManager uses to report the calling application whenever a sensor event occurred. This callback interface has following methods:
abstract void onAccuracyChanged(Sensor sensor, int accuracy)
abstract void onSensorChanged(SensorEvent event)
The onAccuractChanged method is called when there is a change in the sensor accuracy. First parameter is the Sensor registered and second one is the accuracy value. This can be one of the following:
SensorManager.SENSOR_STATUS_ACCURACY_HIGH - high accuracy
SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM - medium accuracy
SensorManager.SENSOR_STATUS_ACCURACY_LOW - low accuracy
SensorManager.SENSOR_STATUS_UNRELIABLE - accuracy is unreliable and cannot be trusted
The onSensorChanged is called when the sensor values are changed. The only argument SensorEvent is the sensor event occurred. This class holds the sensor values, accuracy of the sensor values, Sensor itself and a timestamp at which the event occurred.
SensorEvent.values contains the sensor values. This is an array offloat values representing the sensor values. The length and content of this array depends on the type of sensor used. For example if the sensor is an accelerometer then it will be having three elements representing Azimuth angle, Pitch and Roll. Other sensors have different values. Sensor values are described in this link.

Thursday, July 14, 2011

ADB Commands for sign in the apk files

Signing Android apk
Open cmd prompt , by default it will be C:\\Users\ganesh.v
Create a key store:
keytool -genkey -v -keystore Navionicskey.keystore -alias Navionics -keyalg RSA -keysize 2048 -validity 10000
Navionicskey.keystore will be generated in the path C:\\Users\ganesh.v
Sign the apk:
Jarsigner  -verbose  -keystore  Navionicskey.keystore  D:\Project\Android\it.navionics.norway.apk Navionics
D:\Project\Android\it.navionics.norway.apk  : absolute path to apk or you can copy apk to the current path
Verify if the apk is signed properly or not:
jarsigner  -verify  -verbose  -certs  D:\Project\Android\it.navionics.norway.apk


Sign in With Other Keys  Like  Shared keys ,Platform Keys and Etc


1) Export unsigned apk to keys folder.
 2) keys path > java -jar signapk.jar testkey.x509.pem testkey.pk8 apkname newname.apk
 3) path > adb install signed.apk
 4) run command: adb shell am instrument -w packagename/android.test.InstrumentationTestRunner

Wednesday, July 13, 2011

Helpful Hints for Android App Development


Helpful Hints for Android App Development

While solving problems with Android is a simple task, you may get to the point in app development where you're not sure what to do. The following list should point you in the right direction when you’re in need of help.
  • Not sure how to solve a particular problem? Visit the forums at StackOverflow.com and use the Android tag. StackOverflow is an Android platform–recommended destination for developer questions.
  • The most common tasks have already been done for you. A list of common tasks and instructions on how to do them are provided by the Android developer Web site.
  • If you’re not sure what a package or class does, place your cursor over the object or class while inside Eclipse to view the documentation pop-up window. If no tool tip exists, you can view the documentation online at Android Developer Reference.
  • To find all references of a particular object in your class file, select the object and press Ctrl+Shift+G.
  • To make the stream messages in the DDMS perspective more readable, create a filter that specifically applies to your application logging.
  • When typing into Eclipse, you sometimes know the name of the destination property, method, or class you’d like to create. However, it does not yet exist. Type the name in the component, Eclipse will inform you that the component cannot be found. Now select it, and press F2. This gives you a small pop-up window that allows you to create through the click of a button.
  • To quickly navigate around a class file, press Ctrl+O and start typing the name of the member you’re interested in. Select it from the pop-up list and press Enter.
  • To quickly navigate among the tabs in the Eclipse IDE, press Shift+Page Up or Shift+Page Down.
  • To quickly run your Android application, press Ctrl+Shift+F11.

Eclipse Keyboard Shortcuts

You’ll most likely spend most of your Android development career in the Eclipse IDE. The following table shows a few keyboard shortcuts that can help you save a lot of time.
ActionKeyboard Shortcut
Create a new file in the current packageAlt+Shift+N
Organize the import statementsCtrl+Shift+O
Navigate to the source definitionF3
Rename an objectAlt+Shift+R
Search through Java filesCtrl+H
Open a particular typeCtrl+Shift+T
Find declarationsCtrl+G
Navigate leftAlt+left-pointing arrow
Navigate rightAlt+left-pointing arrow

Common Android Intent Usage

You’ll use a few basic intents most of the time while developing mobile apps for Androids. The following table shows you the code for several basic Android intents.
IntentCode
Start an activitystartActivity(new Intent(this, Destination.class));
Create a chooserIntent.createChooser(yourIntent, "Please Select");
Open the Web browserIntent i = new
Intent(Intent.ACTION_VIEW,
Uri.parse("http://example.org")); startActivity(i);
Start activity for a resultstartActivityForResult(yourIntent, YOUR_REQUEST_CODE);

Developing Applications for Multiple Screen Sizes in Android

One of the challenges that you will encounter during your time as an Android app developer is developing for multiple screen sizes. There are many things to keep in mind during your adventure into screen sizes. The following list below should help keep you on track.
  • The size requirements for each icon in each density vary for each type of icon. You find launcher icons, menu icons, status bar icons, tab icons, and many more. They are all built differently for each screen density. When building these icons, reference the Android Icon Design Guidelines.
  • Try to always use the density-independent pixel (dip) measurement unit when defining your user interface. This helps your application scale to different devices. The density-independent pixel is a virtual pixel that scales proportionally for each given screen density.
  • Provide the supports-screens element to the AndroidManifest.xml file to help the Android market determine whether your application is compatible with various screen sizes.
  • Provide graphics for high-, medium-, and low-density devices. While this may increase your development and design time, it will greatly improve the usability and appearance of your application.

Sunday, July 3, 2011

The complete understanding of Activity Life Cycle in Android

Here i am describing the complete activity life cycle methods.


The above diagram will explain what are the life cycle methods and how they will work. 

Main Components and Building Blocks of Android SDK

Hi all,

To know about android architecture, please click on this link below   http://developer.android.com/guide/basics/what-is-android.html

The above site will gives complete guidance for android developers.


The main components of android are

1.Activities
2.Services
3.Content Providers
4.Broadcast Receivers


The communication of above components will be done using

Intents, and IntentFilters