Java tutorial
//package com.java2s; /* * Copyright (c) 2016 Vladimir L. Shabanov <virlof@gmail.com> * * Licensed under the Underdark License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://underdark.io/LICENSE.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.bluetooth.BluetoothAdapter; import android.content.Context; import android.os.Build; public class Main { public static String getLocalAddress(Context context) { // http://stackoverflow.com/a/33749218 // http://stackoverflow.com/a/34494459 String address = ""; if (Build.VERSION.SDK_INT <= 22) { address = BluetoothAdapter.getDefaultAdapter().getAddress(); } else { address = android.provider.Settings.Secure.getString(context.getContentResolver(), "bluetooth_address"); } return address; } }