Android commandid ********************************************************************

Source: Internet
Author: User

Android commandid ********************************************************************

Ç° ~~~ónyangíí» § ******************************************************** *************************************************


Ö± ********************************************************************

Ç° æ á½ ¸ öic _ mp_shake_off_btn Ç çá ~~~~í ~~~£;× {{{'{{± {{ui × öá {{{{} comment '****£.

Ó Ï Â À 'Í Ê çaudio _ player. xml Ä ä~~µä~~~~䣰 £%â ~â ~ö~í~~~~~~~~~~~~~~~~~{{{{{° '¥-hangzhouúäämöµø · £.

¶ Ó ózäµ ¸ Ä äæ äë ~~~%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Ó Ï Â À 'químázó Ô ózózäzö' £° String. xml <symbol · Character "http://www.bkjia.com/kf/ware/vc/" target = "_ blank" class = "keylink"> vcD4KPHA + PHByZSBjbGFzcz0 = "brush: java;"> Please refer to the following link for more information. Zookeeper» zookeeper. ~~~Úómañane ~µä· ~~² ² × ~~~°¥.

Ó Ï Â À '{ä äò {{%^ö² ¥ · {µäö÷ À £° MediaPlaybackActivity. java

{× ~~~~Í~ó ± äá~£° private ImageButton mShakeButton;

Ó Ï Â À 'Ô Ù Í ¨ ý findViewById À' Ê µà ý» ¯ ¡Ò ° '¥ ¥² ¢ í ¼ Ó À à £ £.»

    mShakeButton = ((ImageButton) findViewById(R.id.shake));    mShakeButton.setOnClickListener(mShakeListener); 

Ú ú° ¯ ý onConfigurationChanged ² xöímaññean limit µä² limit × £»

    mShakeButton = ((ImageButton) findViewById(R.id.shake));    mShakeButton.setOnClickListener(mShakeListener); 
~Öyangúomíà '{µomöà À Ì {µä° {{£»

    private View.OnClickListener mShakeListener = new View.OnClickListener() {        public void onClick(View v) {            shakeEnable();        }    };

Comment 'shakeenable () ° then limit µä° then limit £»

    private void shakeEnable(){if (mService == null) {return;}try {if (mService.getShakeFlag()== false){mService.setShakeFlag(true);showToast(R.string.shake_on_notif);}else{mService.setShakeFlag(false);showToast(R.string.shake_off_notif);}setShakeButtonImage();}catch (RemoteException ex) {        }    }

Ô úserviceconnection À ï Þ ¸ Ä ä° '{¥äé é² {× {° íéörärírírí??£ £»

Comment 'setshakebuttonimage ° then comment £°

   private void setShakeButtonImage() {        if (mService == null) return;          try {if  (mService.getShakeFlag() == false) {mShakeButton.setImageResource(R.drawable.ic_mp_shake_off_btn);}else{mShakeButton.setImageResource(R.drawable.ic_mp_shake_on_btn);}   }catch (RemoteException ex) {        }    }

MediaPlaybackActivity. java Õ â ö öî ä¼ Ð þ ° ä° Ã á~£»


Ó Ï Â À 'alipay' MediaPlaybackService. java

~È import onShakeListener

import com.android.music.ShakeDetector.onShakeListener;

É ê à ÷ ±äá¿ £°

Private boolean mShakeFlag = false;

ShakeDetector mShakeDetector = null;

Ô úoncreate () öð 'ó sharedpreference öð ááè; the value»

  mShakeFlag = mPreferences.getBoolean("shakeflag", false);  setShakeOnorOff();

~Úondestroy () ö~~~~~× ~² £°

   if (mShakeDetector != null) {mShakeDetector.unRegisterListener();   }
Limit μ Ï ö° then limit £°

    private void setShakeOnorOff(){ if (mShakeFlag == true){         mShakeDetector= new ShakeDetector(this); mShakeDetector.registerListener(); mShakeDetector.setOnShakeListener(new onShakeListener() { @Override public void onShake() { // TODO Auto-generated method stub if (isPlaying()){      gotoNext(true); } } }); }else{if (mShakeDetector != null) {mShakeDetector.unRegisterListener();} }Editor ed = mPreferences.edit();ed.putBoolean("shakeflag", mShakeFlag);SharedPreferencesCompat.apply(ed); }    public void setShakeFlag(boolean shakeflag) {        synchronized (this) {            mShakeFlag = shakeflag;            setShakeOnorOff();        }    }    public boolean getShakeFlag() {        return mShakeFlag;    }

~Úimediaplaybackservice.

      public void setShakeFlag(boolean shakeflag) {    mService.get().setShakeFlag(shakeflag);          }        public boolean getShakeFlag() {            return mService.get().getShakeFlag();        }

Ó Ï Â À 'Í í Ê çāúimediaplaybackservice. aidl Ä äö Ö öð Í ¼ íó Ó Ô Ó µ µä° ¯ £ £»

   void setShakeFlag(boolean shakeflag);    boolean getShakeFlag();

×Î ° óguíç çoríó ó Ò» ö öî ä~~shakedetector. java

package com.android.music; import android.content.Context;import android.hardware.Sensor;import android.hardware.SensorEvent;import android.hardware.SensorEventListener;import android.hardware.SensorManager;import android.util.Log;public class ShakeDetector implements SensorEventListener {private static final String TAG = "ShakeDetector";private Context mContext;private long lastTime;        private float last_x;private float last_y;private float last_z;private static final double SHAKE_SHRESHOLD = 3000d;//Õâ¸öÖµ¿É¸ù¾ÝsensorµÄÁéÃô¶ÈÀ´µ÷Õû        private Sensor sensor;private SensorManager sensorManager;public onShakeListener shakeListener;public ShakeDetector(Context context) {mContext = context;sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);}       public boolean registerListener() {if (sensorManager != null) {sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);if (sensor != null) {this.sensorManager.registerListener(this, sensor,SensorManager.SENSOR_DELAY_GAME);return true;}}return false;}public void unRegisterListener() {System.out.println("ShakeDetector:unRegisterListener");if (sensorManager != null  && sensor != null)sensorManager.unregisterListener(this , sensor);}public void setOnShakeListener(onShakeListener listener) {shakeListener = listener;}@Overridepublic void onAccuracyChanged(Sensor sensor, int accuracy) {// TODO Auto-generated method stub}@Overridepublic void onSensorChanged(SensorEvent event) {// TODO Auto-generated method stublong curTime = java.lang.System.currentTimeMillis();if ((curTime - lastTime) > 50) {long diffTime = (curTime - lastTime);lastTime = curTime;float x = event.values[0];float y = event.values[1];float z = event.values[2];                                float speed = Math.abs(x + y + z - last_x - last_y - last_z)/ diffTime * 10000;System.out.println("ShakeDetector:onSensorChanged speed ="+speed);if (speed > SHAKE_SHRESHOLD) {shakeListener.onShake();}last_x = x;last_y = y;last_z = z;}}       public interface onShakeListener {public void onShake();}}

° £;{Μ;'{{{ö{£ ****************************************************** ~~~ózózózomé ~zäzäzäzäzämézézézézézézézézézézézézézézézézézézézézézézézé £°{{n' £;mtk £%%² ?********************************************************** â Ç Ô ú° ó æ ámámañañawithout without £.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.