コード例 #1
0
	//弹出框按钮的点击事件
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.ll_share:
//			Toast.makeText(getApplicationContext(), "分享的程序名称:" + appInfo.getName(), 0).show();
			shareApplication();
			break;
		case R.id.ll_start:
//			Toast.makeText(getApplicationContext(), "打开的程序名称:" + appInfo.getName(), 0).show();
			startApplication();
			break;
		case R.id.ll_uninstall:
			if (appInfo.isUserApp()) {
//				Toast.makeText(getApplicationContext(), "卸载的程序名称:" + appInfo.getName(), 0).show();
				uninstallAppliation();
			} else {
				Toast.makeText(this, "系统程序,不能卸载", 0).show();
			}
			break;

		default:
			break;
		}
		
		
		
	}
コード例 #2
0
	/**
	 * 分享
	 */
	private void shareApplication() {
		// TODO Auto-generated method stub
		Intent intent = new Intent();
		intent.setAction("android.intent.action.SEND");
		intent.addCategory(Intent.CATEGORY_DEFAULT);
		intent.setType("text/plain");
		intent.putExtra(Intent.EXTRA_TEXT, "推荐软件,名称:" + appInfo.getName());
		startActivity(intent);
	}
コード例 #3
0
	/**
	 * 卸载程序
	 */
	private void uninstallAppliation() {
		// TODO Auto-generated method stub
		Intent intent = new Intent();
		intent.setAction("android.intent.action.VIEW");
		intent.setAction("android.intent.action.DELETE");
		intent.addCategory("android.intent.category.DEFAULT");
		intent.setData(Uri.parse("package:" + appInfo.getPackname()));
		startActivityForResult(intent, 0);
		
	}
コード例 #4
0
	/**
	 * 启动程序
	 */
	private void startApplication() {
		// TODO Auto-generated method stub
		//查询此应用程序的入口activity,然后启动
		//包管理器
		PackageManager pm = getPackageManager();
		
//		Intent intent = new Intent();
//		intent.setAction("android.intent.action.MAIN");
//		intent.addCategory("android.intent.category.LAUNCHER");
//		//查询手机上的所有具有驱动能力的activity
//		List<ResolveInfo> infos = pm.queryIntentActivities(intent, PackageManager.GET_INTENT_FILTERS);
		
		//启动所点击的应用
		Intent intent = pm.getLaunchIntentForPackage(appInfo.getPackname());
		if (intent != null) {
			startActivity(intent);
		} else {
			Toast.makeText(this, "无法启动", 0).show();
		}
	}
コード例 #5
0
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub'
			AppInfo newappInfo;
			
			//用户程序数量
			if (position == 0) {
				TextView tv = new TextView(getApplicationContext());
				tv.setTextColor(Color.WHITE);
				tv.setBackgroundColor(Color.GRAY);
				tv.setText("用户程序:" + userAppInfos.size() + "个");
				return tv;
			} else if (position == userAppInfos.size() + 1) {
				TextView tv = new TextView(getApplicationContext());
				tv.setTextColor(Color.WHITE);
				tv.setBackgroundColor(Color.GRAY);
				tv.setText("系统程序:" + systemAppInfos.size() + "个");
				return tv;
			} else if (position <= userAppInfos.size()) {
				//用户程序
				//因为多了一个TextView的文本占用了一个位置
				int newposition = position - 1;
				newappInfo = userAppInfos.get(newposition);
			} else {
				//系统程序
				
				int newposition = position - 1 - userAppInfos.size() - 1;
				newappInfo = systemAppInfos.get(newposition);
			}
			

			View view;
			ViewHolder holder;
			
			//复用缓存的view对象,并且判断缓存的对象类型,避免复用不合适的类型
			if (convertView != null && convertView instanceof RelativeLayout) {
				view = convertView;
				holder = (ViewHolder) view.getTag();
			} else {
				view = View.inflate(getApplicationContext(), R.layout.list_item_appinfo, null);
				holder = new ViewHolder();
				holder.iv_icon = (ImageView) view.findViewById(R.id.iv_app_icon);
				holder.tv_name = (TextView) view.findViewById(R.id.tv_app_name);
				holder.tv_location = (TextView) view.findViewById(R.id.tv_app_location);
				holder.iv_status = (ImageView) view.findViewById(R.id.iv_status);
				view.setTag(holder);
				
			}
			
//			if (position < userAppInfos.size()) {
//				//用户程序显示位置
//				newappInfo = userAppInfos.get(position);
//			} else {
//				//系统程序显示位置
//				int newposition = position - userAppInfos.size();
//				newappInfo = systemAppInfos.get(newposition);
//			}
			
			holder.iv_icon.setImageDrawable(newappInfo.getIcon());
			holder.tv_name.setText(newappInfo.getName());
			
			if (newappInfo.isInRom()) {
				holder.tv_location.setText("手机内存");
			} else {
				holder.tv_location.setText("外部存储");
			}
			
			
			
			if (dao.find(newappInfo.getPackname())) {
				holder.iv_status.setImageResource(R.drawable.lock);
			} else {
				holder.iv_status.setImageResource(R.drawable.unlock);
			}
			
			
			
			return view;
		}