Skip to content

Instantly share code, notes, and snippets.

@ueno-yuhei
Last active August 29, 2015 14:01
Show Gist options
  • Save ueno-yuhei/1127adb3f4eee032f81a to your computer and use it in GitHub Desktop.
Save ueno-yuhei/1127adb3f4eee032f81a to your computer and use it in GitHub Desktop.
Bluetooth 他の端末から検出可能にする
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 100);
startActivity(discoverableIntent); //他Bluetoothでバイスから100秒検出可能にする
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment