導航:首頁 > 操作系統 > android自動匹配

android自動匹配

發布時間:2022-08-14 20:44:30

android 怎麼實現屏幕的自動匹配

在AndroidManifest.xml中定義如下:
<supports-screens
android:largeScreens=」true」
android:normalScreens=」true」
android:smallScreens=」true」
android:resizable=」true」
android:anyDensity=」true」 />

⑵ Android是怎樣匹配資源的

針對大多數APK應用程序,開發人員都會提供各種不同的資源。比如對於同一張圖片image.png,我們通常會提供高解析度,中解析度和低解析度三個版本。

res/
drawable/
image.png
drawable-hdpi/
image.png
drawable-mdpi/
image.png
drawable-ldpi/
image.png

它們都必須以相同的名字存儲在各個drawable目錄下。當應用程序運行時,系統會根據當前設備的實際解析度來選擇最佳的資源。

那麼系統運行時如何動態選擇最合適的資源來使用呢?

理解最佳資源的匹配過程至少有兩個好處:

  1. 當設計應用程序時,我們可以有針對性地提供正確的資源。
  2. 對於適配多種設備有重要的指導意義。
資源標簽屬性及優先順序

理解最佳資源匹配過程之前,我們先來看一下資源標簽的屬性和優先順序。所謂優先順序順序指的是Android規定的資源標簽屬性的優先順序。
其實除了解析度外,同種資源之間還可以有下面許多資源屬性標簽,它們在匹配過程中是有優先順序順序的。

以下資源標簽修飾語按照優先順序從高到低的順序排列。

⑶ android本地api文檔 檢索功能不能自動匹配

直接把自己在知乎的回答過得拷貝過來,希望對大家有作用。

一、原因

不能索索的根本原因是瀏覽器無法訪問Google,伺服器無法響應裡面的Ajax。

二、解決辦法

方法1:使用Mozilla Firefox瀏覽器,點擊「文件」選擇「離線模式」,然後在瀏覽器裡面輸入android sdk的docs路徑,比如:file:///E:/androidstudio/sdk/docs/reference/packages.html 。 然後再去搜索的時候就可以了。

方法2:將docs文件放到tomcat裡面,然後運行tomcat,再通過localhost訪問文檔。這種方式還是有點慢,推薦第一種。

⑷ 如何實現Android藍牙開發 自動配對連接,並不彈出提示框

android藍牙自動配對連接的具體代碼如下: 1. 獲取藍牙適配器BluetoothAdapter blueadapter=BluetoothAdapter.getDefaultAdapter(); 如果BluetoothAdapter 為null,說明android手機沒有藍牙模塊。 2. 判斷藍牙模塊是否開啟,blueadapter.isEnabled() true表示已經開啟,false表示藍牙並沒啟用。 3. 啟動配置藍牙可見模式,即進入可配對模式Intent in=new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); in.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 200); startActivity(in); ,200就表示200秒。 4. 獲取藍牙適配器中已經配對的設備Set<BluetoothDevice> device=blueadapter.getBondedDevices(); 當然,還需要在androidManifest.xml中聲明藍牙的許可權 <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> 5.自動配對設置Pin值 static public boolean autoBond(Class btClass, BluetoothDevice device, String strPin) throws Exception { Method autoBondMethod = btClass.getMethod("setPin", new Class[] { byte[].class }

⑸ android藍牙配對 如何自動配對設置PIN碼

Android對於音頻設備是自動輸入0000的pin碼的,參照$frameworks/base/core/java/android/server/BluetoothEventLoop.java 的onRequestPinCode()你若是在app里編寫代碼,可以在收到ACTION_PAIRING_REQUEST的時候,直接調用BluetoothDevice.setpin()reference $package/apps/Settings/src/android/settings/bluetooth/BluetoothPairingDialog.java 的onPair();

⑹ android 怎麼實現藍牙的自動匹配和連接

eoe 看到過:

<receiver android:name=".broadcast.PairingRequest">
<intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" /$amp;>amp;$nbsp;
<action android:name="android.bluetooth.device.action.PAIRING_CANCEL" /$amp;>amp;$nbsp;
</intent-filter>
</receiver>

public class PairingRequest extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent){
if (intent.getAction().equals("ACTION_PAIRING_REQUEST")) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
byte[] pinBytes = BluetoothDevice.convertPinToBytes("1234");
device.setPin(pinBytes);
}
}
}

其中的藍牙BluetoothDevice這個類要用源碼里的替換下(不然會缺少方法)。

⑺ 如何實現android藍牙自動配對連接

望你踩吶我的回答

下面是自動配對的代碼
Mainfest,xml注冊
<receiver android:name="." >
<intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
</intent-filter>
</receiver>

自己在收到廣播時處理並將預先輸入的密碼設置進去

public class extends BroadcastReceiver
{

String strPsw = "0";

@Override
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
if (intent.getAction().equals(
"android.bluetooth.device.action.PAIRING_REQUEST"))
{
BluetoothDevice btDevice = intent
.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

// byte[] pinBytes = BluetoothDevice.convertPinToBytes("1234");
// device.setPin(pinBytes);
Log.i("tag11111", "ddd");
try
{
ClsUtils.setPin(btDevice.getClass(), btDevice, strPsw); // 手機和藍牙採集器配對
ClsUtils.createBond(btDevice.getClass(), btDevice);
ClsUtils.cancelPairingUserInput(btDevice.getClass(), btDevice);
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}
}

<b>/************************************ 藍牙配對函數 * **************/
import java.lang.reflect.Field;
import java.lang.reflect.Method;

import android.bluetooth.BluetoothDevice;
import android.util.Log;
public class ClsUtils
{

/**
* 與設備配對 參考源碼:platform/packages/apps/Settings.git
* /Settings/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
*/
static public boolean createBond(Class btClass, BluetoothDevice btDevice)
throws Exception
{
Method createBondMethod = btClass.getMethod("createBond");
Boolean returnValue = (Boolean) createBondMethod.invoke(btDevice);
return returnValue.booleanValue();
}

/**
* 與設備解除配對 參考源碼:platform/packages/apps/Settings.git
* /Settings/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
*/
static public boolean removeBond(Class btClass, BluetoothDevice btDevice)
throws Exception
{
Method removeBondMethod = btClass.getMethod("removeBond");
Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice);
return returnValue.booleanValue();
}

static public boolean setPin(Class btClass, BluetoothDevice btDevice,
String str) throws Exception
{
try
{
Method removeBondMethod = btClass.getDeclaredMethod("setPin",
new Class[]
{byte[].class});
Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice,
new Object[]
{str.getBytes()});
Log.e("returnValue", "" + returnValue);
}
catch (SecurityException e)
{
// throw new RuntimeException(e.getMessage());
e.printStackTrace();
}
catch (IllegalArgumentException e)
{
// throw new RuntimeException(e.getMessage());
e.printStackTrace();
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;

}

// 取消用戶輸入
static public boolean cancelPairingUserInput(Class btClass,
BluetoothDevice device)

throws Exception
{
Method createBondMethod = btClass.getMethod("cancelPairingUserInput");
// cancelBondProcess()
Boolean returnValue = (Boolean) createBondMethod.invoke(device);
return returnValue.booleanValue();
}

// 取消配對
static public boolean cancelBondProcess(Class btClass,
BluetoothDevice device)

throws Exception
{
Method createBondMethod = btClass.getMethod("cancelBondProcess");
Boolean returnValue = (Boolean) createBondMethod.invoke(device);
return returnValue.booleanValue();
}

/**
*
* @param clsShow
*/
static public void printAllInform(Class clsShow)
{
try
{
// 取得所有方法
Method[] hideMethod = clsShow.getMethods();
int i = 0;
for (; i < hideMethod.length; i++)
{
Log.e("method name", hideMethod[i].getName() + ";and the i is:"
+ i);
}
// 取得所有常量
Field[] allFields = clsShow.getFields();
for (i = 0; i < allFields.length; i++)
{
Log.e("Field name", allFields[i].getName());
}
}
catch (SecurityException e)
{
// throw new RuntimeException(e.getMessage());
e.printStackTrace();
}
catch (IllegalArgumentException e)
{
// throw new RuntimeException(e.getMessage());
e.printStackTrace();
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}</b>

執行時直接使用:

<b>public static boolean pair(String strAddr, String strPsw)
{
boolean result = false;
BluetoothAdapter bluetoothAdapter = BluetoothAdapter
.getDefaultAdapter();

bluetoothAdapter.cancelDiscovery();

if (!bluetoothAdapter.isEnabled())
{
bluetoothAdapter.enable();
}

if (!BluetoothAdapter.checkBluetoothAddress(strAddr))
{ // 檢查藍牙地址是否有效

Log.d("mylog", "devAdd un effient!");
}

BluetoothDevice device = bluetoothAdapter.getRemoteDevice(strAddr);

if (device.getBondState() != BluetoothDevice.BOND_BONDED)
{
try
{
Log.d("mylog", "NOT BOND_BONDED");
ClsUtils.setPin(device.getClass(), device, strPsw); // 手機和藍牙採集器配對
ClsUtils.createBond(device.getClass(), device);
remoteDevice = device; // 配對完畢就把這個設備對象傳給全局的remoteDevice
result = true;
}
catch (Exception e)
{
// TODO Auto-generated catch block

Log.d("mylog", "setPiN failed!");
e.printStackTrace();
} //

}
else
{
Log.d("mylog", "HAS BOND_BONDED");
try
{
ClsUtils.createBond(device.getClass(), device);
ClsUtils.setPin(device.getClass(), device, strPsw); // 手機和藍牙採集器配對
ClsUtils.createBond(device.getClass(), device);
remoteDevice = device; // 如果綁定成功,就直接把這個設備對象傳給全局的remoteDevice
result = true;
}
catch (Exception e)
{
// TODO Auto-generated catch block
Log.d("mylog", "setPiN failed!");
e.printStackTrace();
}
}
return result;
}</b>

⑻ android自動匹配的下拉菜單快捷鍵怎麼調出來

需要修改config.xml文件、String.xml文件和添加矢量圖xml文件或添加一張png圖片。鎖屏開關點擊時不需要動畫,因此不添加動畫xml文件
(1) 在\frameworks\base\packages\SystemUI\res\values\config.xml里找到 "quick_settings_ tiles_default",添加lockscreen,用「,」隔開:
<string name="quick_settings_tiles_default" translatable="false">
wifi,bt,inversion,cell,airplane,rotation,flashlight,location,cast,hotspot,lockscreen
</string>
(2) 在\frameworks\base\packages\SystemUI\res\values\string.xml里添加:
<string name="quick_settings_lockscreen_label">
"lockscreen"
</string>
(3) 在\frameworks\base\packages\SystemUI\res\values values-zh-rCN\string.xml里添加:
<string name="quick_settings_lockscreen_label">"鎖屏"</string>
其他語言在相應的values文件夾下對應的string.xml文件里添加。
(4) 在\frameworks\base\packages\SystemUI\res\drawable-hdpi文件夾里添加圖片ic_qs_locks- creen.png,也可以在drawable文件夾下添加矢量圖xml文件;

⑼ 如何讓Android的浮動搜索框具有AutoCompleteTextView的自動匹配功能

其常用屬性定義如下
<AutoCompleteTextView
android:id="@+id/mp002_top_place_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:completionThreshold="1"
android:layout_marginTop="5dp" >
</AutoCompleteTextView>
其中android:completionThreshold定義了從第幾個字元開始顯示候補列表
默認值為2

使用例:
AutoCompleteTextView mPlace = (AutoCompleteTextView)findViewById(R.id.mp002_top_place_input);
ArrayList<String> result = new ArrayList<String>();
result.add("1111111");
result.add("1222222");
mPlace.setAdapter(new ArrayAdapter<String>(
MP002TopActivity.this,
android.R.layout.simple_dropdown_item_1line,
result)
);

局限性是completionThreshold設定的最小值是1
小於1的情況下,會默認變成1。

所以要在不輸入任何字元的條件下顯示候補列表
就必須重載AutoCompleteTextView這個控制項。

public class MyAutoCompleteTextView extends AutoCompleteTextView{
public MyAutoCompleteTextView(Context context) {
super(context);
}
public MyAutoCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean enoughToFilter() {
return true;
}
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(focused, direction, previouslyFocusedRect);
performFiltering(getText(), KeyEvent.KEYCODE_UNKNOWN);
}
}

閱讀全文

與android自動匹配相關的資料

熱點內容
如何修改ie代理伺服器 瀏覽:417
折紙手工解壓玩具不用a4紙 瀏覽:485
怎麼雙向傳輸伺服器 瀏覽:286
電腦如何實現跨網段訪問伺服器 瀏覽:549
模塊化網頁源碼位元組跳動 瀏覽:485
梯度下降演算法中遇到的問題 瀏覽:605
伺服器連接電視怎麼接 瀏覽:323
phploop語句 瀏覽:502
交叉編譯工具鏈里的庫在哪 瀏覽:781
安卓手q換號怎麼改綁 瀏覽:399
nba球星加密貨幣 瀏覽:789
命令看網速 瀏覽:124
java堆分配 瀏覽:161
linuxbuiltin 瀏覽:560
cstpdf 瀏覽:941
texstudio編譯在哪 瀏覽:352
國家反詐中心app注冊登記表怎麼注冊 瀏覽:972
加密機默認埠 瀏覽:101
有哪個網站有免費的python源代碼 瀏覽:305
蘋果手機如何導入安卓電話 瀏覽:915