Я пытаюсь с 4 дней запустить маленькое приложение.Я использую код из BluetoothChat только для проверки, включен ли BT.Если нет, он должен отобразить диалог включения.Я пытаюсь запустить этот код на HTC Wildfire с Android 2.2
package com.example.testagain;
import android.app.Activity;
import android.os.Bundle;
import android.bluetooth.BluetoothAdapter;
import android.util.Log;
import android.widget.Toast;
import android.content.Intent;
public class testit extends Activity {
/** Called when the activity is first created. */
private static final String TAG = "BluetoothChat";
private static final boolean D = true;
private BluetoothAdapter mBluetoothAdapter = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(D) Log.e(TAG, "+++ ON CREATE +++");
// Set up the window layout
setContentView(R.layout.main);
// Get local Bluetooth adapter
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
// If the adapter is null, then Bluetooth is not supported
if (mBluetoothAdapter == null) {
Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
finish();
return;
}
}
@Override
public void onStart() {
super.onStart();
if(D) Log.e(TAG, "++ ON START ++");
// If BT is not on, request that it be enabled.
// setupChat() will then be called during onActivityResult
if (!mBluetoothAdapter.isEnabled()) {
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, 1);
// Otherwise, setup the chat session
} else {
Toast.makeText(this, "done!", Toast.LENGTH_LONG).show();
}
}
}
Где в этом коде ошибка?Спасибо за вашу помощь!Christian