Launcher知识的demo,手机管家小伙家与悬浮窗

Launcher知识的demo,主要仿的手机管家小伙家与悬浮窗的效果。东西比较简单,直接贴代码

主要用到了windowManager 中的更新updateViewLayout(view,params),和 添加windowManager.addView()和删除windowManager.removeView()

移动launcher主要是updateViewLayout(view,params),中的params来实现

贴几个主要类,全部源码请自己下载

package com.pzf.flow;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;
/**
 * 开启服务,用来判断是否是主页面,如果在主页面则显示悬浮窗,否则隐藏悬浮框
 * @author pangzf
 * @time 2014年10月11日 上午11:19:42
 */
public class MyService extends Service {
	private Timer timer;
	private Handler mHandler = new Handler();

	public MyService() {
	}

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}

	@Override
	public void onCreate() {

		super.onCreate();
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		// 开启定时器
		// 判断是否在主页面,如果在主页面同事small没有显示,则显示small
		// 开启定时器,每隔0.5秒刷新一次
		if (timer == null) {
			timer = new Timer();
			timer.scheduleAtFixedRate(new MyTimerTask(), 0, 500);
		}
		return super.onStartCommand(intent, flags, startId);
	}

	private class MyTimerTask extends TimerTask {

		@Override
		public void run() {
			showWindow();
		}

	}

	/**
	 * 判断是否在主页面,如果在主页面同事small没有显示,则显示small
	 */
	private void showWindow() {
		if (MyWindowManager.isHome(getApplicationContext()) && !MyWindowManager.isWindowShowing()) {
			mHandler.post(new Runnable() {

				@Override
				public void run() {
					MyWindowManager.createSmallWindow(getApplicationContext());
				}
			});

		} else if (!MyWindowManager.isHome(getApplicationContext()) && MyWindowManager.isWindowShowing()) {
			// 如果不是主页,但是已经有窗口了,关掉之前的窗口
			mHandler.post(new Runnable() {

				@Override
				public void run() {
					MyWindowManager.removeSmallWindow(getApplicationContext());

				}
			});
		} else if (MyWindowManager.isHome(getApplicationContext()) && MyWindowManager.isWindowShowing()) {
			mHandler.post(new Runnable() {

				@Override
				public void run() {
					 MyWindowManager.updatePercent(getApplicationContext());
				}
			});
		}
	}

	@Override
	public void onDestroy() {
		if (timer != null) {
			timer.cancel();
			timer = null;
		}
		super.onDestroy();
	}

}
package com.pzf.flow;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;

import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.PixelFormat;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.TextView;
/**
 * 管理类,1.用来创建launcher 2.删除launcher 3.更新launcher 4.改变火箭发射台的背景图 5.判断是否主页 6.界面是否存在悬浮框 7。获得运行内存等
 * @author pangzf
 * @time 2014年10月11日 上午11:20:37
 */
public class MyWindowManager {
	private static WindowManager mWindowManager;
	private static LayoutInflater mInflater;
	private static SmallView smallWindow;
	private static WindowManager.LayoutParams smallWindowParams;
	static int screenWidth;
	static int screenHeight;
	private static ActivityManager mActivityManager;
	private static BigView bigView;
	private static LayoutParams bigWindowParams;
	private static RocketLauncher mRocketLauncher;
	private static LayoutParams mRocketWindowParams;

	public MyWindowManager(Context context) {
		mWindowManager = (WindowManager) context
				.getSystemService(Context.WINDOW_SERVICE);
		mInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

	}

	/**
	 * 判断是否是主页面
	 */
	public static boolean isHome(Context context) {
		ActivityManager activityManager = (ActivityManager) context
				.getSystemService(Context.ACTIVITY_SERVICE);
		List<RunningTaskInfo> runningTasks = activityManager.getRunningTasks(1);
		return getHome(context).contains(
				runningTasks.get(0).topActivity.getPackageName());
	}

	/***
	 * 获得主页面
	 *
	 * @return
	 */
	private static List<String> getHome(Context context) {
		PackageManager packageManager = context.getPackageManager();
		Intent intent = new Intent(Intent.ACTION_MAIN);
		intent.addCategory(Intent.CATEGORY_HOME);
		List<String> names = new ArrayList<String>();
		List<ResolveInfo> list = packageManager.queryIntentActivities(intent,
				PackageManager.MATCH_DEFAULT_ONLY);
		if (list != null) {
			for (ResolveInfo info : list) {
				names.add(info.activityInfo.packageName);
			}
		}
		return names;
	}

	/**
	 * 是否有窗口在屏幕上显示
	 *
	 * @return
	 */
	public static boolean isWindowShowing() {
		return smallWindow != null || bigView != null;
	}

	public static void removeSmallWindow(Context context) {
		if (smallWindow != null) {
			WindowManager windowManager = getWindowManager(context);
			windowManager.removeView(smallWindow);
			smallWindow = null;
		}
	}

	/**
	 * 创建小的window
	 */
	// public void createSmallWindow() {
	// mWindowManager=getWindowManager(mContext);
	// screenWidth = mWindowManager.getDefaultDisplay().getWidth();
	// screenHeight = mWindowManager.getDefaultDisplay().getHeight();
	// if (smallView == null) {
	// smallView = new SmallView(mContext);
	//
	//
	// if (mSamllWindowParams == null) {
	// mSamllWindowParams = new LayoutParams();
	// mSamllWindowParams.type = LayoutParams.TYPE_PHONE;
	// mSamllWindowParams.format = PixelFormat.RGBA_8888;
	// mSamllWindowParams.flags = LayoutParams.FLAG_NOT_FOCUSABLE
	// | LayoutParams.FLAG_NOT_TOUCH_MODAL;
	// mSamllWindowParams.gravity = Gravity.LEFT | Gravity.TOP;
	// mSamllWindowParams.width = smallView.getWidth();
	// mSamllWindowParams.height = smallView.getHeight();
	// mSamllWindowParams.x = screenWidth;
	// mSamllWindowParams.y = screenHeight/2;
	// }
	// smallView.setParams(mSamllWindowParams);
	// mWindowManager.addView(smallView, mSamllWindowParams);
	// }
	//
	// }
	public static void createSmallWindow(Context context) {
		WindowManager windowManager = getWindowManager(context);
		int screenWidth = windowManager.getDefaultDisplay().getWidth();
		int screenHeight = windowManager.getDefaultDisplay().getHeight();
		if (smallWindow == null) {
			smallWindow = new SmallView(context);
			if (smallWindowParams == null) {
				smallWindowParams = new LayoutParams();
				smallWindowParams.type = LayoutParams.TYPE_SYSTEM_ALERT;
				smallWindowParams.format = PixelFormat.RGBA_8888;
				smallWindowParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
						| LayoutParams.FLAG_NOT_FOCUSABLE;
				smallWindowParams.gravity = Gravity.LEFT | Gravity.TOP;
				smallWindowParams.width = smallWindow.viewWidth;
				smallWindowParams.height = smallWindow.viewHeight;
				smallWindowParams.x = screenWidth;
				smallWindowParams.y = screenHeight / 2;
			}
			smallWindow.setParams(smallWindowParams);
			windowManager.addView(smallWindow, smallWindowParams);
		}
	}

	private static WindowManager getWindowManager(Context context) {
		if (mWindowManager == null) {
			mWindowManager = (WindowManager) context
					.getSystemService(Context.WINDOW_SERVICE);
		}
		return mWindowManager;
	}

	/**
	 * 计算已使用内存的百分比
	 *
	 * @return
	 */
	public static String getUserPercent(Context context) {
		String dir = "/proc/meminfo";
		try {
			// FileReader fr=new FileReader(dir);
			// BufferedReader br = new BufferedReader(fr, 2048);
			// String data = br.readLine();
			// String subMemoryLine = data.substring(data.indexOf("MemTotal:"));
			// br.close();
			// long totalMemorySize =
			// Integer.parseInt(subMemoryLine.replaceAll("\\D+", ""));
			// long avaliableMemory= getAvalibaleMemory(context)/1024;
			// int
			// percent=(int)((totalMemorySize-avaliableMemory)/((float)totalMemorySize*100));
			// return percent+"%";
			FileReader fr = new FileReader(dir);
			BufferedReader br = new BufferedReader(fr, 2048);
			String memoryLine = br.readLine();
			String subMemoryLine = memoryLine.substring(memoryLine
					.indexOf("MemTotal:"));
			br.close();
			long totalMemorySize = Integer.parseInt(subMemoryLine.replaceAll(
					"\\D+", ""));
			long availableSize = getAvalibaleMemory(context) / 1024;
			int percent = (int) ((totalMemorySize - availableSize)
					/ (float) totalMemorySize * 100);
			return percent + "%";

		} catch (Exception e) {
			e.printStackTrace();
		}

		return "悬浮窗";

	}

	/**
	 * 返回可用的内存
	 *
	 * @param context
	 * @return
	 */
	private static long getAvalibaleMemory(Context context) {
		MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
		getActivityManager(context).getMemoryInfo(memoryInfo);
		return memoryInfo.availMem;
	}

	private static ActivityManager getActivityManager(Context context) {
		if (mActivityManager == null) {
			mActivityManager = (ActivityManager) context
					.getSystemService(Context.ACTIVITY_SERVICE);
		}
		return mActivityManager;
	}

	public static void updatePercent(Context context) {
		if (smallWindow != null) {
			((TextView) smallWindow.findViewById(R.id.tv_small_percent))
					.setText(getUserPercent(context));
		}
	}

	public static void createBigView(Context context) {
		WindowManager windowManager = getWindowManager(context);
		int screenWidth = windowManager.getDefaultDisplay().getWidth();
		int screenHeight = windowManager.getDefaultDisplay().getHeight();
		if (bigView == null) {
			bigView = new BigView(context);
			if (bigWindowParams == null) {
				bigWindowParams = new LayoutParams();
				bigWindowParams.x = screenWidth / 2 - BigView.viewWidth / 2;
				bigWindowParams.y = screenHeight / 2 - BigView.viewHeight / 2;
				bigWindowParams.type = LayoutParams.TYPE_PHONE;
				bigWindowParams.format = PixelFormat.RGBA_8888;
				bigWindowParams.gravity = Gravity.LEFT | Gravity.TOP;
				bigWindowParams.width = BigView.viewWidth;
				bigWindowParams.height = BigView.viewHeight;
			}
			windowManager.addView(bigView, bigWindowParams);
		}

	}

	/**
	 * 将大悬浮窗从屏幕上移除。
	 *
	 * @param context
	 *            必须为应用程序的Context.
	 */
	public static void removeBigWindow(Context context) {
		if (bigView != null) {
			WindowManager windowManager = getWindowManager(context);
			windowManager.removeView(bigView);
			bigView = null;
		}
	}

	// 火箭---------------
	/**
	 * 创建小火箭
	 *
	 * @param context
	 */
//	public static void createRocketWindow(Context context) {
//		WindowManager windowManager = getWindowManager(context);
//		int screenWidth = windowManager.getDefaultDisplay().getWidth();
//		int screenHeight = windowManager.getDefaultDisplay().getHeight();
//		if (mRocketLauncher == null) {
//			mRocketLauncher = new RocketLauncher(context);
//			if (mRocketWindowParams == null) {
//				mRocketWindowParams = new LayoutParams();
//				mRocketWindowParams.x = screenWidth / 2 - mRocketLauncher.mRocketWith/2;
//				mRocketWindowParams.y = screenHeight - mRocketLauncher.mRocketHeight;
//
//				mRocketWindowParams.type = LayoutParams.TYPE_PHONE;
//				mRocketWindowParams.format = PixelFormat.RGBA_8888;
//				mRocketWindowParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
//						| LayoutParams.FLAG_NOT_FOCUSABLE;
//				mRocketWindowParams.gravity = Gravity.LEFT | Gravity.TOP;
//				mRocketWindowParams.width = mRocketLauncher.mRocketWith;
//				mRocketWindowParams.height = mRocketLauncher.mRocketHeight;
//			}
//			windowManager.addView(mRocketLauncher, mRocketWindowParams);
//		}
//	}
//
    /**
     * 创建一个火箭发射台,位置为屏幕底部。
     */
    public static void createRocketWindow(Context context) {
        WindowManager windowManager = getWindowManager(context);
        int screenWidth = windowManager.getDefaultDisplay().getWidth();
        int screenHeight = windowManager.getDefaultDisplay().getHeight();
        if (mRocketLauncher == null) {
        	mRocketLauncher = new RocketLauncher(context);
            if (mRocketWindowParams == null) {
            	mRocketWindowParams = new LayoutParams();
            	mRocketWindowParams.x = screenWidth / 2 - RocketLauncher.mRocketWith / 2;
            	mRocketWindowParams.y = screenHeight - RocketLauncher.mRocketHeight;
            	mRocketWindowParams.type = LayoutParams.TYPE_PHONE;
            	mRocketWindowParams.format = PixelFormat.RGBA_8888;
            	mRocketWindowParams.gravity = Gravity.LEFT | Gravity.TOP;
            	mRocketWindowParams.width = RocketLauncher.mRocketWith;
            	mRocketWindowParams.height = RocketLauncher.mRocketHeight;
            }
            windowManager.addView(mRocketLauncher, mRocketWindowParams);
        }
    } 

	/**
	 * 移除小火箭l
	 *
	 * @param context
	 */
	public static void removeRocketWindow(Context context) {
		WindowManager windowManager = getWindowManager(context);
		if (mRocketLauncher != null) {
			windowManager.removeView(mRocketLauncher);
			mRocketLauncher = null;
		}
	}

    /**
     * 更新火箭发射台的显示状态。
     */
    public static void updateLauncher() {
        if (mRocketLauncher != null) {
        	mRocketLauncher.updateRocketLaucher(isReadyToLaunch());
        }
    }  

	/**
	 * 判断小火箭是否准备好发射了。
	 *
	 * @return 当火箭被发到发射台上返回true,否则返回false。
	 */
	public static boolean isReadyToLaunch() {
		if ((smallWindowParams.x > mRocketWindowParams.x && smallWindowParams.x
				+ smallWindowParams.width < mRocketWindowParams.x
				+ mRocketWindowParams.width)
				&& (smallWindowParams.y + smallWindowParams.height > mRocketWindowParams.y)) {
			return true;
		}
		return false;
	}

}
package com.pzf.flow;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
/**
 * 小火箭的launcer的布局类,此处需要注意mRocketWith,mRocketHeight这两个字段需要public供外界使用,因为在你移动悬浮框的时候需要显示小火箭,这时候需要小火箭的宽和高
 * @author pangzf
 * @time 2014年10月11日 上午11:22:32
 */
public class RocketLauncher extends LinearLayout {

	public static int mRocketWith;
	public static int mRocketHeight;
	private ImageView mRocket;

	public RocketLauncher(Context context) {
		super(context);
		LayoutInflater.from(context).inflate(R.layout.launcher, this);
		mRocket = (ImageView) findViewById(R.id.launcher_img);
		mRocketWith = mRocket.getLayoutParams().width;
		mRocketHeight = mRocket.getLayoutParams().height;
	}
	/**
	 * 是否是发射状态
	 * @param isReadyLaunch
	 */
	public void updateRocketLaucher(boolean isReadyLaunch){
		mRocket.setImageResource(isReadyLaunch?R.drawable.launcher_bg_fire:R.drawable.launcher_bg_hold);
	}

}
package com.pzf.flow;

import java.lang.reflect.Field;

import android.content.Context;
import android.os.AsyncTask;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
 * 悬浮框类
 * 1.显示内存使用情况
 * 2.移动悬浮框,位置改变  OnTouch();
 * 3.移动小悬浮框,变成小火箭 updateView() updateStatus();
 * 4.移动到发射台,小火箭发射 LaunchTask
 * @author pangzf
 * @time 2014年10月11日 上午11:23:48
 */
public class SmallView extends LinearLayout {

	private Context mContext;
	private int statusBarHeight;
	private float mXInView;
	private float mYInView;
	private float mXDownInScreen;
	private float mYDownInScreen;
	private float mXInScreen;
	private float mYInScreen;
    /**
     * 小悬浮窗的参数
     */
    private WindowManager.LayoutParams mParams;
	public int viewWidth;
	public int viewHeight;
	private WindowManager mWindowManager;
	private LinearLayout view;
	private boolean isPressed;
	private ImageView mIvRocket;
	private int rocketWidth;
	private int rocketHeight;

	public SmallView(Context context) {
		super(context);
		this.mContext=context;
		mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		LayoutInflater.from(context).inflate(R.layout.small, this);
		view = (LinearLayout) findViewById(R.id.ll_small_main);
		viewWidth = view.getLayoutParams().width;
		viewHeight = view.getLayoutParams().height;

		mIvRocket = (ImageView) findViewById(R.id.rocket_img);
		rocketWidth = mIvRocket.getLayoutParams().width;
		rocketHeight = mIvRocket.getLayoutParams().height;

		TextView mTvPercent = (TextView) view
				.findViewById(R.id.tv_small_percent);
		mTvPercent.setText(MyWindowManager.getUserPercent(context));
	}

    /**
     * 将小悬浮窗的参数传入,用于更新小悬浮窗的位置。
     *
     * @param params
     *            小悬浮窗的参数
     */
    public void setParams(WindowManager.LayoutParams params) {
        mParams = params;
    } 

	// 做单击处理和移动small位置
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:

			isPressed=true;
			mXInView = event.getX();
			mYInView = event.getY();
			mXDownInScreen = event.getRawX();
			mYDownInScreen = event.getRawY() - getStatusBarHeight();
			mXInScreen = event.getRawX();
			mYInScreen = event.getRawY()-getStatusBarHeight();
			break;
		case MotionEvent.ACTION_MOVE:
			//移动small
			mXInScreen=event.getRawX();
			mYInScreen=event.getRawY() - getStatusBarHeight();
			updateStatus();
			updateView();
			break;
		case MotionEvent.ACTION_UP:
			isPressed=false;
			if(MyWindowManager.isReadyToLaunch()){
				//发射小火箭
				launchRocket();
			}else{
				updateStatus();
				//判断点击事件
				if(mXDownInScreen==mXInScreen&&mYDownInScreen==mYInScreen){
					//打开big
					openBigWindow();
				}
			}

			break;

		default:
			break;
		}
		return true;
	}
	/**
	 * 发射小火箭
	 */
	private void launchRocket() {
		MyWindowManager.removeRocketWindow(getContext());
		new LuanchTask().execute();
	}

	private class LuanchTask extends AsyncTask<Void, Void, Void>{

		@Override
		protected Void doInBackground(Void... params) {
			while(mParams.y>0){
				mParams.y=mParams.y-10;
				publishProgress();
				SystemClock.sleep(8);
			}
			return null;
		}

		@Override
		protected void onProgressUpdate(Void... values) {
			//根据进度更新小火箭的位置,实现发射效果
			mWindowManager.updateViewLayout(SmallView.this, mParams);
		}

		@Override
		protected void onPostExecute(Void result) {
			super.onPostExecute(result);
			// 火箭升空结束后,回归到悬浮窗状态
			updateStatus();
			mParams.x = (int) (mXDownInScreen - mXInView);
			mParams.y = (int) (mYDownInScreen - mYInView);
			mWindowManager.updateViewLayout(SmallView.this, mParams);

		}

	}

	/**
	 * 更改小火箭的状态
	 */
	private void updateStatus() {
		//如果是按下的状态,而且小火箭是不存在的,则显示小火箭,隐藏悬浮框
		if(isPressed&&mIvRocket.getVisibility()!=View.VISIBLE){
			mParams.width=rocketWidth;
			mParams.height=rocketHeight;
			mWindowManager.updateViewLayout(this, mParams);
			view.setVisibility(View.GONE);
			mIvRocket.setVisibility(View.VISIBLE);
			MyWindowManager.createRocketWindow(getContext());
		}else if(!isPressed){
			//显示悬浮框,隐藏小火箭
			mParams.width=viewWidth;
			mParams.height=viewHeight;
			mWindowManager.updateViewLayout(this, mParams);
			view.setVisibility(View.VISIBLE);
			mIvRocket.setVisibility(View.GONE);
			MyWindowManager.removeRocketWindow(getContext());
		}
	}

	/**
	 * 打开大悬浮窗,同时关闭小悬浮窗。
	 */
	private void openBigWindow() {
		MyWindowManager.createBigView(getContext());
		MyWindowManager.removeSmallWindow(getContext());
	}

	/**
	 * 移动samll在屏幕上的位置
	 */
	private void updateView() {
		mParams.x=(int) (mXInScreen-mXInView);
		mParams.y=(int) (mYInScreen-mYInView);
		mWindowManager.updateViewLayout(this, mParams);
		MyWindowManager.updateLauncher();
	}

	/**
	 * 获得状态栏的高度
	 *
	 * @return
	 */
	private float getStatusBarHeight() {
		if (statusBarHeight == 0) {

			try {

				Class<?> clazz = Class.forName("com.android.internal.R$dimen");
				Object o = clazz.newInstance();
				Field field = clazz.getField("status_bar_height");
				Integer size = (Integer) field.get(o);
				statusBarHeight = getResources().getDimensionPixelSize(size);
			} catch (Exception e) {
				e.printStackTrace();
			}

		}
		return statusBarHeight;
	}

}

效果图

源码地址:点击打开链接

时间: 2024-10-07 19:08:09

Launcher知识的demo,手机管家小伙家与悬浮窗的相关文章

anddroid悬浮窗的手机QQ后台清理不掉的秘密

问题来自于一篇文章:手机QQ后台为何清不掉?MIUI工程师:全靠1像素的页面保命出于好奇,想知道这一像素到底是啥东西,用手机安全管家控制QQ的悬浮窗权限:关闭QQ的悬浮窗权限,通过后台一键清理,重新打开QQ,发现是从splash开始的:打开QQ的悬浮窗权限,一键清理后,打开QQ,发现是直接进入主界面的:说明一键清理未清理QQ,或者清理之后,QQ又自启动了.至于,是未被清理还是自启动,后面再探究一下,这里就说说这个一像素的悬浮窗. Button button = new Button(getApp

手机QQ后台清理不掉的秘密——anddroid悬浮窗

问题来自于一篇文章:手机QQ后台为何清不掉?MIUI工程师:全靠1像素的页面保命 出于好奇,想知道这一像素到底是啥东西,用手机安全管家控制QQ的悬浮窗权限: 关闭QQ的悬浮窗权限,通过后台一键清理,重新打开QQ,发现是从splash开始的: 打开QQ的悬浮窗权限,一键清理后,打开QQ,发现是直接进入主界面的:说明一键清理未清理QQ,或者清理之后,QQ又自启动了. 至于,是未被清理还是自启动,后面再探究一下,这里就说说这个一像素的悬浮窗. Button button = new Button(ge

通过线程通讯获取手机正在运行中的软件及大小(仿手机管家 扫描软件)

其实我原本是只想说一个线程之间的通讯 handler,但是觉得内容有点少,就直接写了个demo.我之前是做过仿手机管家这种软件的(当然只是自己做着好玩的),所以 就提取了一点内容结合线程通讯写了个小的demo. 不说废话了,直接上代码: activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas

我的手机管家(5)骚扰拦截 布局界面

我的手机管家(5)骚扰拦截   布局界面: 添加黑名单, 拦截信息,和电话 主界面: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_

我的手机管家(21) 设置中心

我的手机管家(21) 设置中心 : 包括三个界面:四个功能 (1)电话归属地查询 使用SQLIteDatabase 查询address.db, 查询指定号码的归属地 (2) 检查应用版本更新 (3)关于我的手机管家信息 (4)黑名单服务的开启与关闭 黑名单服务: 通过绑定广播进行短信的拦截, 会比静态注册先拦截短信 通过电话管理器TelephonyManager监听电话状态 一旦有电话打入, 首先进行黑名单对比. package com.chb.myphonesave.service; impo

99手机管家项目的总结

断断续续,终于做完了这个项目(2014-11-24~2015-01-01),感慨万千,真的是白天求生存,晚上求发展. 在手机管家的项目中,实现了手机防盗,通讯卫士,软件管理,进程管理,流量统计,手机杀毒,缓存清理,高级工具,设置中心等功能.使用到的东西: 1.Android四大控件,各大布局. 2.关于ListView的convertView的复用(Listview的优化). 3.ListView的convertView复用带来的数据错乱的问题. 4.AIDL和反射的理解(挂断电话,清理缓存).

我的手机管家(10)病毒扫描 拷贝病毒数据库

我的手机管家(10)病毒扫描    拷贝病毒数据库 (1)将病毒数据库复制到asserts文件夹下,然后复制到 "data/data/com.chb.myphonesafe/files/antivirus.db" //数据库路径必须是data/data目录下,否则无法访问 拷贝:AssetUtil package com.chb.myphonesave.util; import java.io.File; import java.io.FileOutputStream; import

我的手机管家(11) 网络助手 界面设计及适配器

我的手机管家(11)   网络助手  界面设计 使用一个 <SlidingDrawer>标签用来布局一个抽屉样式 两个属性要注意: 一个是内容布局id,   手柄id android:content="@+id/content" android:handle="@+id/handle" android:orientation="vertical" 抽出的方向 <SlidingDrawer android:id="@+i

类似腾讯手机管家应用源码完整版

类似腾讯手机管家应用源码,也是自己写的android手机管家,内附源代码,应用实现了手机防功能,通信卫士功能,软件管家,进程管理,手机杀毒等功能,里面的图片部分用到了腾讯手机管家的图片,所以跟腾讯手机管家应用比较类似了,大家可以参考一下,可能有的功能还没有那么完善,不过大家可以再这个基础上进行升级,创新,增加自己的特色吧.或者大家可以看看安装演示版(附件下面) 源码项目下载:http://code.662p.com/view/8982.html <ignore_js_op> <ignor