Menu Home


Android FW: Create Floating Window

private void initFloatingWindow() { mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); mWindow = PolicyManager.makeNewWindow(mContext); mWindow.setWindowManager(mWindowManager, null, null); mWindow.requestFeature(Window.FEATURE_NO_TITLE); mDecor = mWindow.getDecorView(); mDecor.setOnTouchListener(mTouchListener); mWindow.setContentView(this); mWindow.setBackgroundDrawableResource(android.R.color.transparent); // While the media controller is up, the volume control keys should // affect the media stream type mWindow.setVolumeControlStream(AudioManager.STREAM_MUSIC); setFocusable(true); setFocusableInTouchMode(true); setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); requestFocus(); } ref:

Android: Check Long Press Helper

基本思想: 在Down事件中向UI线程塞入一个定时任务,如果在定时时间终了前任务没有被取消,就认为是一个长按事件。 /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the “License”); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * * […]

Android:FragmentPagerAdapter Demo

package com.example.sijiewang.testviewpager; import android.os.Bundle; import; import; import; import; import; import java.util.ArrayList; public class MainActivity extends FragmentActivity { private ViewPager mAlarmCreateViewPager; private Fragment mFragmentOne; private Fragment mFragmentTwo; private ArrayList<Fragment> mFragmentList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mFragmentList = new ArrayList<Fragment>(2); mFragmentOne = new mFragmentOne(); […]

Android的坑: Intent setData and setType

public Intent setData (Uri data) Added in API level 1 Set the data this intent is operating on. This method automatically clears any type that was previously set by setType(String) or setTypeAndNormalize(String). Note: scheme matching in the Android framework is case-sensitive, unlike the formal RFC. As a result, you should […]

Android:onTouchEvent & TouchListener的执行

public boolean dispatchTouchEvent(MotionEvent event) { if (mInputEventConsistencyVerifier != null) { mInputEventConsistencyVerifier.onTouchEvent(event, 0); } if (onFilterTouchEventForSecurity(event)) { // noinspection SimplifiableIfStatement ListenerInfo li = mListenerInfo; if (li != null && li.mOnTouchListener != null && (mViewFlags & ENABLED_MASK) == ENABLED && li.mOnTouchListener.onTouch(this, event)) { return true; } if (onTouchEvent(event)) { return true; } […]

Andorid Wear调试

通过USB adb -d forward tcp:5601 tcp:5601 通过蓝牙 1、在手机端打开Android Wear应用 2、点击界面右上的菜单并选择设置(Settings) 3、开启“通过蓝牙调试”(Debugging over Bluetooth)。你可以看到设备连接状态: Host: disconnected Target: connected 4、手机用usb连接电脑,并执行adb命令: adb forward tcp:4444 localabstract:/adb-hub; adb connect localhost:4444 你就可以看到刚才的连接状态就变成了: Host: connected Target: connected