Tuesday, August 22, 2017

App marketing Strategy - How to make your successful

Below are some of the strategy for App marketing

  • Simply rewording your app’s top description on the Android Market, for example, may result in an increase of 10–25 downloads per day if your original wording did not get right to the point.
  • Your strategy for obtaining reviews for your app should be to contact as many Android app review sites as possible that are likely to review your app.
  • Send message for website blogs to wirte a blog on the app
  • You will want to make sure the following items are updated to carry your new app’s message
  • Icon— Carefully evaluate your app’s icon to ensure that the graphic describes your app and conveys the value of your app. 
  • Website— All content on your website should express, convey, and highlight your unique message (for example, fast action play), thus leaving no doubt in the minds of your customers as to the key values of your app.
  • Improving the app graphics displayed on the Android Market will help you increase your downloads by some percentage as well.
  • Android Market app page— All your content and graphics displayed on the Android Market will help direct readers to your app’s key values and encourage them make a buying decision concerning your app. The first few sentences on your Android Market page that describe your app are crucial. Make sure you get right to the heart of what your app does and the value it provides in the first two sentences.

Direct marketing for your app

           Direct marketing includes mailing and emailing.

Promoting your app

  • Newspapers

Subject Line: New Android App Helps Owners Keep Their Gardens Alive!
Dear Editor (use his or her real name),
I have recently completed this exciting new Android app that allows an Android user to take care of their gardens with clear pictures, descriptions, and tips for many garden varieties across the U.S. and Canada. Because of your coverage of home and garden topics, I feel this app would be of great interest to you and your readers. I would be happy to provide you with a free copy of this app and give you a demonstration of its benefits. I look forward to hearing your response!
Kind Regards,
Your Name
Your Phone Number

  • Advertising Your Apps

                  AdMob offers pay-per-click (CPC) advertising on thousands of mobile websites and Android apps for Android developers. You decide how much to pay per click through AdMob’s auction-based pricing system. The minimum amount to start an ad campaign is $50.
Mobclix is another ad platform that provides analytics and monetization through advertising and distribution for application developers.

  • Paid Search

Google, Yahoo!, and other search engines provide the capability to perform a paid search to locate your product website.
When they perform a search, your website will appear in the “paid” listings section of these search engines. When a user clicks over to your website, you are charged a fee for each click through.
Online advertising includes placing company information, products, descriptions of your apps, and so on, in online listings, including Android app directories.

Building a community

                Maintaining an accurate user list or having a way to reach out to your customers is imperative to a successful customer-retention program. 

Facebook :  First, you want to be found by people who are interested in buying your Android apps. Second, you want to connect with these potential customers and establish a relationship with them. You can use Facebook to create a business page for your app within a few minutes. Once you have completed all the details for your page, you can then invite your friends to become fans of your business (app) page. This will help you to initiate the viral marketing process for your app. When people join your Fan Page, it’s published in their newsfeed for all their friends to read, thus further helping the word to get out about your app.

Twitter : When you do a press release, be sure to Tweet out to your followers with a link to your announcement. Ask your followers to do you a favor and re-Tweet the post to their followers. This will help you spread the word about your app, and this helps you establish a sense of community with like-minded users of your app.
Using Blogs : The first and easiest way to utilize blogging is to get to know some bloggers who write about Android and Android tablet apps.

Using LinkedIN : Its power for you as an app marketer lies in the fact that there are literally thousands of groups you can review and join to take part in discussions and promote your apps. 

Using Youtube : So, a video is a must when you are trying to market your Android and Android tablet apps. Your video should be posted on your product website and blog. It should also be used when contacting reviewers to attract their attention.

Here are a few basic ideas to help you develop your Android and Android tablet app video:
• Keep the video short! No more than two minutes in length.
• Make your video engaging. Humor, where appropriate, doesn’t hurt.
• Write out a script to cover what you will say in the video. Shooting the video without a script will look like, well, you shot the video without a script!
• Present the video in a “problem/solution/demo” format. State the problem your buyer is having. Then state the solution your app provides. Demonstrate the app in a brief demo.
• In your video, ask the buyer to go to your product web page or blog, as well as to the Android Market, to learn more.

Why Have a Marketing Plan

So, following the popular Top Ten List format, here are the top ten reasons you should create a marketing plan. 

1. Focuses on your target market
2. Allocates marketing funds
3. Measures your progress
4. Provides a roadmap for growth
5. Helps you obtain funding
6. Coordinates your app launches
7. Sets realistic sales targets
8. Evaluates your competitors
9. Sets prices and defines promotions
10. Defines a strong value proposition

Share:

How to become freelancer developer


Freelancer

                   A freelancer or freelance worker is a term commonly used for a person who is self-employed and is not necessarily committed to a particular employer long-term. Freelance workers are sometimes represented by a company or a temporary agency that resells freelance labor to clients; others work independently or use professional associations or websites to get work.

ADVANTAGES OF THE FREELANCE LIFE

  • Flexible working hours : The ability to work the hours you want is a huge advantage for most people. Family commitments and school runs, part-time study, or simply your internal body clock’s unique cycle may mean that you prefer to work early in the morning, or late into the evening.
  • Flexible work location : Work from any location
  • Choice of projects : As a freelancer, once you’re established, you’re in control—you have the opportunity to refuse projects or clients.
  • Being in charge : The feeling of strength and autonomy that comes from being in charge of your life’s direction is a major drawcard.
  • Constant education : Freelancing can allow you the flexibility to spend more time on research and planned education than would a normal nine-to-five job.
  • Variety of projects : Wide variety of projects you have the opportunity to work across multiple industries and switch your focus between large and small projects
DISADVANTAGES OF THE FREELANCE LIFE

  • Financial insecurity : Easily the biggest disadvantage for many people is that ocean effect upon the bank balance. This problem can largely be avoided by understanding, controlling, and being acutely aware of your cash flow.
  • Loneliness : It’s not uncommon for freelancers to feel absolutely cut off from the rest of the world, especially if they’re single and working from home.
  • No Fixed schedule : Blurring of home and work times
  • Wearing all those different hats :  This can, of course, also become an issue when your clients start thinking they can call you anytime.Wearing all those different hats selling, marketing, bookkeeping, dealing with legal matters, debt collecting, and the like.
  • Loss of salaried benefits : Freelancers are susceptible to letting themselves down when it comes to health benefits, holiday planning, superannuation, and insurance.
Skills Required for Freelancing

  • Technical Skills : For a developer, possessing technical skills means that you’re technically competent in your language or languages of choice: PHP, Ruby on Rails, Microsoft .NET, and the like. Consider your areas of weakness, and research what’s involved in strengthening these areas—you’ll probably find that they’re easier to fill out than you thought.
  • Business Skills : It’s vitally important to have, or at least be aware of, the fundamentals of business before you consider running your own. If you plan to succeed, you’ll need a solid understanding of cash flow, marketing, time management, customer service, and other areas.
  • Organizational Skills : Your ability to be well organized, or at the very least to keep on top of those dreary administrative duties, will be paramount to your success. Start by reading personal productivity books and blogs, and research the different techniques of organization.
  • Interpersonal Skills : You may think that the freelance life would suit the shy or socially inept recluse, beavering away alone. Unfortunately, however, an aversion to social contact could limit your opportunities more than you think.
  • Productive interaction with clients and prospective clients, not to mention your suppliers, will become a crucial part of your success, so embrace human contact and be personable.

Successful Freelancer Personality Traits

Typically, though, these are the predominant personality traits and abilities you’ll be likely to find in a successful freelancer:

  • Ambition
  • An aptitude for problem solving
  • Courage
  • A mature outlook
  • A high level of communication skills
  • A strong work ethic
  • Perfectionism
  • A professional attitude
  • Self-confidence


In real-life terms, this means that to be a successful freelancer, you should be able to find resonance in many of the following characteristics; ideally, you:
  • Believe organization includes keeping the workspace tidy and planning ahead
  • Form short-term and long-term plans, preferably detailed on paper
  • Remain calm and able to work through issues in times of stress
  • Are able to handle a high level of responsibility
  • Understand that research goes beyond a two-minute Google search
  • Appreciate the role of financial planning
  • Are passionate about design or development, or both
  • Understand that budgeting means planning ahead, not spending every cent as it comes in value your health as important, so that you exercise and get regular checkups
  • Consider freelancing because you believe you can be successful, not just to escape your current job
  • Understand selling and embrace the process
  • Have a good support network of family and friends
  • Acknowledge that cash flow is vital to success
  • Appreciate that education is a continual process, not a once-off effort to gain a qualification
  • Plan towards gaining a work–life balance, and not work round the clock
  • Realize that customer service is about empathy and understanding, not just saying sorry after the fact
Share:

Thursday, April 20, 2017

Android Sensor - Tutorial


Android Sensors 

              Sensors measure a particular kind of physical quantity, such as force acting on device, light falling on a surface, or the temperature in a room.

               The majority of the sensors are Micro Electro Mechanical Sensors (MEMS), which are made on a tiny scale (in micrometers), usually on a silicon chip, with mechanical and electrical elements integrated together. The basic working principle behind MEMS is to measure the change in electric signal originating due to mechanical motion. This change in electric signals is converted to digital values by electric circuits. The accelerometer and gyroscope are the main examples of MEMS


Types of sensor values

Sensor values can be broadly divided into the following three categories:
  • Raw: These values are directly given by the sensor. The operating system simply passes these values to the apps without adding any correction logic. Accelerometers, proximity sensors, light sensors, and barometers are sensors that give raw values.

  • Calibrated: These values are computed by the operating system by adding extra correction algorithms, such as drift compensation and removing bias and noise over the raw values given by sensors. Step detector, step counter, and significant motion are sensors that give calibrated values by using an accelerometer as their base sensor. The magnetometer and gyroscope are special kinds of sensor that give both raw and calibrated values.

  • Fused: These values are derived from a combination of two or more sensors. Generally, these values are calculated by leveraging the strength of one sensor to accommodate the weaknesses of other sensors. Gravity and linear acceleration give fused values by using the accelerometer and gyroscope.

Types of sensor

Sensor
Value
Underlying Sensors
Description
Common Usage
Accelerometer
Raw
Accelerometer
This measures the acceleration force along the xy, and z axes (including gravity). Unit: m/s2
It can be used to detect motion such as shakes, swings, tilt, and physical forces applied on the phone.
Gravity
Fused
Accelerometer, Gyroscope
This measures the force of gravity along the xy, and zaxes. Unit: m/s2
It can be used to detect when the phone is in free fall.
Linear Acceleration
Fused
Accelerometer, Gyroscope
It measures the acceleration force along the xy, and z axes (excluding gravity). Unit: m/s2
It can be used to detect motion such as shakes, swings, tilt, and physical forces applied on phone.
Gyroscope
Raw, Calibrated
Gyroscope
This measures the rate of rotation of the device along the xy, and zaxes. Unit: rad/s
It can be used to detect rotation motions such as spin, turn, and any angular movement of the phone.
Step Detector
Calibrated
Accelerometer
This detects walking steps.
It can be used to detect when a user starts walking.
Step Counter
Calibrated
Accelerometer
It measures the number of steps taken by the user since the last reboot while the sensor was activated
It keeps track of the steps taken by the user per day.
Significant Motion
Calibrated
Accelerometer
It detects when there is significant motion on the phone because of walking, running, or driving.
It detects a significant motion event.
Rotation Vector
Fused
Accelerometer, Gyroscope, Magnetometer
This measures the rotation vector component along the xaxis (x * sin(θ/2)), y axis (y * sin(θ/2)), and z axis (z * sin(θ/2)). Scalar component of the rotation vector ((cos(θ/2)). Unitless.
It can be used in 3D games based on phone direction.

Android Sensor Stack




Components of the sensor framework

                   Android has provided methods, classes, and interfaces for accessing sensors and their data that is available on an Android device. These sets of methods, classes, and interfaces are collectively referred to as the sensor framework and are a part of the android.hardwarepackage. It consists of four major components: SensorManagerSensorSensorEvent, and SensorEventListener. The entry point to the framework is the SensorManagerclass, which allows an app to request sensor information and register to receive sensor data. When registered, sensor data values are sent to a SensorEventListener interface in the form of a SensorEvent class that contains information produced from a given sensor.


SensorManager

         SensorManager is the class that makes it possible for your app to get access to the sensors. It creates the instance of the system sensor service, which provides various APIs to access sensor information on the device. It exposes the methods that list the available and default sensors on the device. This class also provides several sensor constants that are used to report sensor accuracy, sampling period, and calibrate sensors. One of the important tasks of this class is to register and unregister sensor event listeners for accessing a particular sensor.

SensorEventListener
        SensorEventListener is the interface that provides two callbacks to receive the sensor notification (sensor event). OnSensorChanged() is the first method of the interface, which is called whenever there is any change in the sensor values. The change in sensor value is communicated through the SensorEvent object, passed as a parameter to this method. OnAccuracyChanged() is the second method, which is called whenever there is a change in the accuracy of sensor values. The sensor object and newly reported accuracy in integers are sent as parameters to this method. There are four accuracy integer constants supported by SensorManager. They are as follows:
  • SENSOR_STATUS_ACCURACY_HIGH
  • SENSOR_STATUS_ACCURACY_MEDIUM
  • SENSOR_STATUS_ACCURACY_LOW
  • SENSOR_STATUS_ACCURACY_UNRELIABLE

Sensor
        Sensor is the class that is used to create an instance of a specific sensor. This class provides various methods that let you determine a sensor's capabilities:
  • Maximum Range
  • Minimum Delay
  • Name
  • Power
  • Resolution
  • Reporting Mode
  • Type
  • Vendor
  • Version
  • isWakeUp Sensor

SensorEvent
        SensorEvent is a special kind of class that is used by the operating system to report changes in the sensor values to the listeners. This SensorEvent object contains the following four elements:
  • values[]: This is a multidimensional array that holds the sensor values
  • timestamp: This refers to the time in nanoseconds at which the event happened
  • accuracy: This is one of the four accuracy integer constants
  • sensor: This is the sensor type that generated this data


Checking the availability of the sensor at runtime

private SensorManager mSensorManager;
...
mSensorManager=
(SensorManager)getSystemService(Context.SENSOR_SERVICE);
if(mSensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE)!=null){
  // Success! There's a pressure sensor.
}else{
  // Failure! No pressure sensor.
}

Example
       import android.app.Activity;
       import android.content.Context;
       import android.hardware.Sensor;
       import android.hardware.SensorEvent;
       import android.hardware.SensorEventListener;
       import android.hardware.SensorManager;
       import android.os.Bundle;

       public class SensorActivity extends Activity implements
       SensorEventListener{
       private SensorManager mSensorManager;
       private Sensor mSensor;

       @Override
       protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
    
       mSensorManager =
       (SensorManager)this.getSystemService
       (Context.SENSOR_SERVICE );

       if(mSensorManager.getDefaultSensor
       (Sensor.TYPE_GYROSCOPE)!= null){
       mSensor =
       mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
       }
     }
@Override
       protected void onResume() {
         super.onResume();
         mSensorManager.registerListener(this, mSensor,
         SensorManager.SENSOR_DELAY_NORMAL);
       }

       @Override
       protected void onPause() {
         super.onPause();
         mSensorManager.unregisterListener(this);
       }

       @Override
       protected void onDestroy() {
         super.onDestroy();
         mSensorManager = null;
         mSensor = null;
       }
@Override
        public void onSensorChanged(SensorEvent event) {
            //event.values[] (do something with sensor values)
           //event.timestamp (do something with timestamp)
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int
        accuracy)
        {
            //Do something with changed accuracy
           //This method is mandatory to defined
        }

Listing the available sensors on a device


public class SensorListActivity extends Activity
       implements OnItemClickListener{

         private SensorManager mSensorManager;
         private ListView mSensorListView;
         private ListAdapter mListAdapter;
         private List<Sensor> mSensorsList;
@Override
     protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);

       mSensorManager =
       (SensorManager)this.getSystemService
       (Context.SENSOR_SERVICE);

       mSensorsList =
       mSensorManager.getSensorList(Sensor.TYPE_ALL);
       mSensorListView =
       (ListView)findViewById(R.id.session_list);
       mListAdapter = new ListAdapter();
       mSensorListView.setAdapter(mListAdapter);
       mSensorListView.setOnItemClickListener(this);  
     }
     private class ListAdapter extends BaseAdapter{ 

      private TextView mSensorName;

   
      @Override
      public int getCount() {
        return mSensorsList.size();
      }

      @Override
      public Object getItem(int position) {
        return mSensorsList.get(position).getName();
      }

      @Override
      public long getItemId(int position) {
        return position;
      }

      @Override
      public View getView(int position, View convertView,
      ViewGroup parent) {

      if(convertView==null){
        convertView = 
        getLayoutInflater().inflate(R.layout.list_rows,
        parent, false);
      }

      mSensorName =
      (TextView)convertView.findViewById(R.id.sensor_name);
      mSensorName.setText(mSensorsList.get(position)
      .getName());
      return convertView;
      }
   }
@Override
     public void onItemClick(AdapterView<?> parent, View view,
     int position,long id) {
    
       Intent intent = new Intent(getApplicationContext(),
       SensorCapabilityActivity.class);
       intent.putExtra(getResources()
       .getResourceName(R.string.sensor_type),
       mSensorsList.get(position).getType());
  
       startActivity(intent);
     }

Wake locks, wakeup sensors, and the FIFO queue

Wake lock can be obtained using the PowerManager object, which is provided by the system power service. The newWakeLock() method of PowerManager provides the object of wake lock. This newWakeLock() method accepts the type of wake lock and string tag for identification purposes.
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"myLock");
mWakeLock.acquire();
 //Do some important work in background.
 mWakeLock.release();

Using the fingerprint sensor

          In order to support the fingerprint sensor, the Android platform has introduced a new system service, which is called the Finger Print Service, and it can be accessed using the instance of FingerprintManager.
Fingerprint sensor APIs require install time permission in the AndroidManifest.xmlfile (android.permission.USE_FINGERPRINT) and also runtime permission before using them.

public class FingerPrintActivity extends Activity { 

          private static final int FINGERPRINT_PERMISSION_REQUEST_CODE = 0;
          private FingerprintManager mFingerprintManager;
          //Alias for our key in the Android Key Store
          private static final String KEY_NAME = "my_key";
          private KeyStore mKeyStore;
          private KeyGenerator mKeyGenerator;
          private Cipher mCipher;
          private CancellationSignal mCancellationSignal;
          private Dialog mFingerPrintDialog;

          @Override
          protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.fingerprint_layout);
            mFingerprintManager = (FingerprintManager)getSystemService
            (FINGERPRINT_SERVICE);
            //As soon as Activity starts, check for the finger print
            conditions
            checkFingerPrintConditions()
          }

          public void initiateFingerPrintSensor(View v) {
            //Called from Layout button
            checkFingerPrintConditions();
          }


public void checkFingerPrintConditions() {

          if(mFingerprintManager.isHardwareDetected()) {
            if(mFingerprintManager.hasEnrolledFingerprints()) {
              if(ContextCompat.checkSelfPermission(this,
              Manifest.permission.USE_FINGERPRINT)!=
              PackageManager.PERMISSION_GRANTED) {
                //Requesting runtime finger print permission
                requestPermissions(new String[]
                {Manifest.permission.USE_FINGERPRINT},
                FINGERPRINT_PERMISSION_REQUEST_CODE);
              } else {
                //After all 3 conditions are met, then show FingerPrint
                Dialog
                showFingerPrintDialog();
              }
            } else {
              showAlertDialog("Finger Print Not Registered!", "Go to
              'Settings -> Security -> Fingerprint' and register at least
              one fingerprint");
            }
          } else {
            showAlertDialog("Finger Print Sensor Not Found!", "Finger Print
            Sensor could not be found on your phone.");
          }
        }

        @Override
        public void onRequestPermissionsResult(int requestCode, String[]
        permissions, int[] state) {

          //show FingerPrint Dialog, when runtime permission is granted
          if (requestCode == FINGERPRINT_PERMISSION_REQUEST_CODE
          && state[0] == PackageManager.PERMISSION_GRANTED) {

            showFingerPrintDialog();
          }
        }

        public void showAlertDialog(String title, String message){
          new android.app.AlertDialog.Builder(this).setTitle(title)    
          .setMessage(message).setIcon(android.R.drawable.ic_dialog_alert)
          .setPositiveButton("Cancel", new DialogInterface
          .OnClickListener()               
          {
             public void onClick(DialogInterface dialog, int whichButton) 
             {
                dialog.dismiss();
             }})
            .show();
          }


public void showFingerPrintDialog() {
          //First Initialize the FingerPrint Settings
          if(initFingerPrintSettings())
          {
            //Init Custom FingerPrint Dialog from xml
            mFingerPrintDialog = new Dialog(this);
            View view = LayoutInflater.from(this).inflate
            (R.layout.fingerpring_dialog, null, false);
            mFingerPrintDialog.setContentView(view);
            Button cancel = (Button) view.findViewById(R.id.cancelbutton);
            cancel.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View arg0) {
                mCancellationSignal.cancel();
                mFingerPrintDialog.dismiss();
              }
            });

            //Stops the cancelling of the fingerprint dialog
            //by back press or touching accidentally on screen
            mFingerPrintDialog.setCanceledOnTouchOutside(false);
            mFingerPrintDialog.setCancelable(false);
            mFingerPrintDialog.show();
          }
          else
          {
            showAlertDialog("Error!", "Error in initiating Finger Print
            Cipher or Key!");
          }
        }

        public boolean initFingerPrintSettings() {

          //CancellationSignal requests authenticate api to stop scanning 
          mCancellationSignal = new CancellationSignal();
          if(initKey() && initCipher()) {
            mFingerprintManager.authenticate(new
            FingerprintManager.CryptoObject(mCipher),
            mCancellationSignal, 0, new AuthenticationListener(), null);
            return true;
          } else {
            return false;
          }
        }

public boolean initKey() {
          try {
            mKeyStore = KeyStore.getInstance("AndroidKeyStore");
            mKeyStore.load(null);
            mKeyGenerator = KeyGenerator.getInstance
            (KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
            mKeyGenerator.init(new KeyGenParameterSpec.Builder(KEY_NAME,
            KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
            .setBlockModes(KeyProperties.BLOCK_MODE_CBC)
            .setUserAuthenticationRequired(true)                
            .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
            .build());
            mKeyGenerator.generateKey();
            return true;
          } catch (Exception e) {
            return false;
          }
        }

        public boolean initCipher() {
          try {
            mKeyStore.load(null);
            SecretKey key = (SecretKey) mKeyStore.getKey(KEY_NAME, null); 
            mCipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES +
            "/" + KeyProperties.BLOCK_MODE_CBC + "/" +
            KeyProperties.ENCRYPTION_PADDING_PKCS7);
            mCipher.init(Cipher.ENCRYPT_MODE, key);
            return true;
          } catch (KeyStoreException | CertificateException |
          UnrecoverableKeyException | IOException |
          NoSuchAlgorithmException | InvalidKeyException |
          NoSuchPaddingException e) {
            return false;
          }
        }


  class AuthenticationListener extends
        FingerprintManager.AuthenticationCallback{

          @Override
          public void onAuthenticationError(int errMsgId, CharSequence
          errString) {

            Toast.makeText(getApplicationContext(), "Authentication
            Error!", Toast.LENGTH_LONG).show();
          }

          @Override
          public void onAuthenticationHelp(int helpMsgId, CharSequence
          helpString) {
          }

          @Override
          public void onAuthenticationFailed() {

            Toast.makeText(getApplicationContext(), "Authentication
            Failed!", Toast.LENGTH_LONG).show();
          }

          @Override
          public void onAuthenticationSucceeded
          (FingerprintManager.AuthenticationResult result) {
             Toast.makeText(getApplicationContext(), "Authentication
            Success!", Toast.LENGTH_LONG).show();
            mFingerPrintDialog.dismiss();
          }
        }

The Step Counter and Detector Sensors – The Pedometer App

    public class StepsCounterActivity extends Activity
        implements SensorEventListener{

        private SensorManager mSensorManager;
        private Sensor mSensor;
        private boolean isSensorPresent;
        private TextView mStepsSinceReboot;

        @Override
        protected void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.stepcounter_layout);
        
          mStepsSinceReboot = (TextView)findViewById
          (R.id.stepssincereboot);
        
          mSensorManager = (SensorManager)
          this.getSystemService(Context.SENSOR_SERVICE);
          if(mSensorManager.getDefaultSensor
          (Sensor.TYPE_STEP_COUNTER) != null) {
            mSensor = mSensorManager.getDefaultSensor
            (Sensor.TYPE_STEP_COUNTER);
            isSensorPresent = true;
          } else {
            isSensorPresent = false;
          }
        }

        @Override
        protected void onResume() {
          super.onResume();
          if(isSensorPresent) {
            mSensorManager.registerListener(this, mSensor,
            SensorManager.SENSOR_DELAY_NORMAL);
          }
        }

        @Override
        protected void onPause() {
          super.onPause();
          if(isSensorPresent) {
            mSensorManager.unregisterListener(this);
          }
        }

        @Override
        public void onSensorChanged(SensorEvent event) {
          mStepsSinceReboot.setText("Steps since reboot:" +
          String.valueOf(event.values[0]));
        }
Share:

Popular Posts

Contact Form

Name

Email *

Message *