protected void bttest() {
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED:
int x = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, 99);
if (x == BluetoothAdapter.STATE_CONNECTED) {
System.out.println("--------------2222222222222222------4-----");
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
System.out.println(device.getAddress());
System.out.println(device.getName());
System.out.println(device.getBondState());
System.out.println(device.getBluetoothClass());
}
break;
case BluetoothAdapter.ACTION_STATE_CHANGED:
//Bluetooth has been turned on or off.
System.out.println("---------ACTION_STATE_CHANGED---------------------------------------------");
System.out.println(intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, 22));
break;
case BluetoothAdapter.ACTION_DISCOVERY_FINISHED:
System.out.println("--------本地蓝牙适配器已完成设备发现过程。----------------");
break;
case BluetoothAdapter.ACTION_DISCOVERY_STARTED:
System.out.println("-------------本地蓝牙适配器已启动远程设备发现过程。------------");
break;
case BluetoothDevice.ACTION_FOUND:
System.out.println("---------------------发现远程设备。---------------------");
System.out.println(intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE));
BluetoothDevice bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
System.out.println(bluetoothDevice.getName());
System.out.println(bluetoothDevice.getAddress());
break;
}
}
};
IntentFilter intentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
IntentFilter intentFilter1 = new IntentFilter(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
IntentFilter intentFilter2 = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
IntentFilter intentFilter3 = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
IntentFilter intentFilter4 = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(broadcastReceiver, intentFilter);
registerReceiver(broadcastReceiver, intentFilter1);
registerReceiver(broadcastReceiver, intentFilter2);
registerReceiver(broadcastReceiver, intentFilter3);
registerReceiver(broadcastReceiver, intentFilter4);
}
2017年11月17日金曜日
2017年11月12日日曜日
WifiManager.NETWORK_STATE_CHANGED_ACTION
监听WIFI
protected void t1() {
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
System.out.println("-----------------------------------3---------------");
System.out.println(intent.getAction());
if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
if (wifiManager.isWifiEnabled()) {
Get_IP();
To_Notification_Wifi();
}
}
}
};
IntentFilter intentFilter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION);
registerReceiver(broadcastReceiver, intentFilter);
}
protected void t1() {
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
System.out.println("-----------------------------------3---------------");
System.out.println(intent.getAction());
if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
if (wifiManager.isWifiEnabled()) {
Get_IP();
To_Notification_Wifi();
}
}
}
};
IntentFilter intentFilter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION);
registerReceiver(broadcastReceiver, intentFilter);
}
2017年11月5日日曜日
Wifi 一覧
Wifi 一覧
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
protected void show_wifi_ssid() {
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager.isWifiEnabled()) {
List<ScanResult> scanResults = wifiManager.getScanResults();
for (ScanResult x : scanResults) {
System.out.println("--------------------------------------------");
System.out.println(x.toString());
System.out.println(x.BSSID);
System.out.println(x.SSID);
System.out.println(x.capabilities);
}
} else {
Toast.makeText(this, "WifiNull", Toast.LENGTH_SHORT).show();
}
}
I/System.out: SSID: AirPort61998, BSSID: 34:76:c5:5e:f2:2e, capabilities: [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS], level: -87, frequency: 2432, timestamp: 413176363535, distance: ?(cm), distanceSd: ?(cm), wpsState :configured, wpsDeviceName :I-O DATA 802.11n AP Router
I/System.out: 34:76:c5:5e:f2:2e
I/System.out: AirPort61998
I/System.out: [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS]
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
protected void show_wifi_ssid() {
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager.isWifiEnabled()) {
List<ScanResult> scanResults = wifiManager.getScanResults();
for (ScanResult x : scanResults) {
System.out.println("--------------------------------------------");
System.out.println(x.toString());
System.out.println(x.BSSID);
System.out.println(x.SSID);
System.out.println(x.capabilities);
}
} else {
Toast.makeText(this, "WifiNull", Toast.LENGTH_SHORT).show();
}
}
I/System.out: SSID: AirPort61998, BSSID: 34:76:c5:5e:f2:2e, capabilities: [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS], level: -87, frequency: 2432, timestamp: 413176363535, distance: ?(cm), distanceSd: ?(cm), wpsState :configured, wpsDeviceName :I-O DATA 802.11n AP Router
I/System.out: 34:76:c5:5e:f2:2e
I/System.out: AirPort61998
I/System.out: [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS]
2017年11月4日土曜日
Google 翻訳 の再生ファイルの保存の方法
2017年10月29日日曜日
SupportActionBar 背景色変更
SupportActionBar 背景色変更
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
int color = android.R.color.black;
Drawable backgroundDrawable = getApplicationContext().getResources().getDrawable(color);
actionBar.setBackgroundDrawable(backgroundDrawable);
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
int color = android.R.color.black;
Drawable backgroundDrawable = getApplicationContext().getResources().getDrawable(color);
actionBar.setBackgroundDrawable(backgroundDrawable);
2017年10月16日月曜日
assets フォルダ内の画像を読み込み
assets フォルダ内の画像を読み込み
AssetManager assetManager = getAssets();
ImageView imageView = (ImageView) findViewById(R.id.imageView);
InputStream inputStream = null;
try {
inputStream = assetManager.open("g1213.png");
} catch (IOException e) {
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
imageView.setImageBitmap(bitmap);
AssetManager assetManager = getAssets();
ImageView imageView = (ImageView) findViewById(R.id.imageView);
InputStream inputStream = null;
try {
inputStream = assetManager.open("g1213.png");
} catch (IOException e) {
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
imageView.setImageBitmap(bitmap);
2017年10月15日日曜日
登録:
投稿 (Atom)