最終更新:
moonlight_aska 2012年06月17日(日) 00:40:10履歴
Bluetoothの設定画面を呼び出すには, インテント(Intent)を利用する.

↓


↓

- Bluetooth02.java
- ACTION_BLUETOOTH_SETTINGSを指定して, Intentのインスタンスを生成する.
- startActivityメソッドで, インテント呼出しする.
package com.moonlight_aska.android.bluetooth02;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Bluetooth02 extends Activity implements View.OnClickListener {
private Button mSettingBtn;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mSettingBtn = (Button)findViewById(R.id.setting_btn);
mSettingBtn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (v == mSettingBtn) {
Intent intent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
startActivity(intent);
}
}
}
コメントをかく