<file_sep>package com.example.cargoexchange;
/**
 * Created by FoolishFan on 2016/7/14.
 */

public class UserData {
    private String userName;                  //鐢ㄦ埛鍚�
    private String userPwd;                   //鐢ㄦ埛瀵嗙爜
    private int userId;                       //鐢ㄦ埛ID鍙�
    public int pwdresetFlag=0;
    //鑾峰彇鐢ㄦ埛鍚�
    public String getUserName() {             //鑾峰彇鐢ㄦ埛鍚�
        return userName;
    }
    //璁剧疆鐢ㄦ埛鍚�
    public void setUserName(String userName) {  //杈撳叆鐢ㄦ埛鍚�
        this.userName = userName;
    }
    //鑾峰彇鐢ㄦ埛瀵嗙爜
    public String getUserPwd() {                //鑾峰彇鐢ㄦ埛瀵嗙爜
        return userPwd;
    }
    //璁剧疆鐢ㄦ埛瀵嗙爜
    public void setUserPwd(String userPwd) {     //杈撳叆鐢ㄦ埛瀵嗙爜
        this.userPwd = userPwd;
    }
    //鑾峰彇鐢ㄦ埛id
    public int getUserId() {                   //鑾峰彇鐢ㄦ埛ID鍙�
        return userId;
    }
    //璁剧疆鐢ㄦ埛id
    public void setUserId(int userId) {       //璁剧疆鐢ㄦ埛ID鍙�
        this.userId = userId;
    }

   /* public UserData(String userName, String userPwd, int userId) {    //鐢ㄦ埛淇℃伅
        super();
        this.userName = userName;
        this.userPwd = <PASSWORD>;
        this.userId = userId;
    }*/

    public UserData(String userName, String userPwd) {  //杩欓噷鍙噰鐢ㄧ敤鎴峰悕鍜屽瘑鐮�
        super();
        this.userName = userName;
        this.userPwd = <PASSWORD>;
    }

}
<file_sep>package com.example.floatView;

import com.example.cargoexchange.R;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.IBinder;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;

public class FloatWindowService extends Service{

	private LayoutParams mWindowParam;
	private WindowManager mWindowManager;
	private LinearLayout mFloatWindow;
	private Button mFLoatBtn;

	public FloatWindowService() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public IBinder onBind(Intent intent) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void onCreate() {
		// TODO Auto-generated method stub
		super.onCreate();
		creatFloatWindow();
	}

	private void creatFloatWindow() {
		mWindowManager = (WindowManager)getApplication().getSystemService(getApplication().WINDOW_SERVICE);
		mWindowParam = new WindowManager.LayoutParams();
		mWindowParam.type = LayoutParams.TYPE_PHONE;
		mWindowParam.format = PixelFormat.RGB_888;
		mWindowParam.flags = LayoutParams.FLAG_NOT_FOCUSABLE;
		mWindowParam.gravity = Gravity.LEFT|Gravity.TOP;
		
		mWindowParam.x = 0;
		mWindowParam.y = 0;
		
		mWindowParam.width = LayoutParams.WRAP_CONTENT;
		mWindowParam.height = LayoutParams.WRAP_CONTENT;
		
		LayoutInflater layoutInflater = LayoutInflater.from(getApplication());
		mFloatWindow = (LinearLayout)layoutInflater.inflate(R.layout.float_window_layout, null);
		
		mWindowManager.addView(mFloatWindow, mWindowParam);
		
		mFLoatBtn = (Button)mFloatWindow.findViewById(R.id.floatBtn);
		
		mFloatWindow.measure(View.MeasureSpec.makeMeasureSpec(0,  
                View.MeasureSpec.UNSPECIFIED), View.MeasureSpec  
                .makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
		
		mFLoatBtn.setOnTouchListener(new View.OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				mWindowParam.x = (int)event.getRawX() - mFLoatBtn.getMeasuredWidth()/2;
				mWindowParam.y = (int)event.getRawY() - mFLoatBtn.getMeasuredHeight()/2 - (int)getStatusBarHeight(getApplicationContext());
				
				mWindowManager.updateViewLayout(mFloatWindow, mWindowParam);
				return false;
			}
		});
		
		mFLoatBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Toast.makeText(getApplicationContext(), "Hello, FloatWindow", Toast.LENGTH_SHORT).show();
			}
		});
	}

	private double getStatusBarHeight(Context context){  
        double statusBarHeight = Math.ceil(25 * context.getResources().getDisplayMetrics().density);  
        return statusBarHeight;  
    } 
	
	@Override
	public void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		if(mFloatWindow != null){
			mWindowManager.removeView(mFloatWindow);
		}
	}
	
	

}
<file_sep>package com.example.floatView;

import com.example.cargoexchange.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class FloatWindowsManagerActivity extends Activity {

	private Button mShowBtn;
	private Button mHideBtn;

	public FloatWindowsManagerActivity() {
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.float_window_manager);

		mShowBtn = (Button) findViewById(R.id.show);
		mHideBtn = (Button) findViewById(R.id.hide);

		if (null != mShowBtn || null != mHideBtn) {
			mShowBtn.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					Intent intent = new Intent(FloatWindowsManagerActivity.this, FloatWindowService.class);
					startService(intent);
					finish();
				}
			});
			mHideBtn.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					Intent intent = new Intent(FloatWindowsManagerActivity.this, FloatWindowService.class);
					stopService(intent);
				}
			});
		}

		/*View.OnClickListener buttonClickListener = new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(FloatWindowsManagerActivity.this, FloatWindowService.class);
				switch (v.getId()) {
				case R.id.show:
					startService(intent);

					break;
				case R.id.hide:
					stopService(intent);
					break;
				}
			}
		};*/
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}
}
