This is a mirror of official site: http://jasper-net.blogspot.com/

Android: Java Class for Blue-tooth BT Enabling

| Tuesday, August 2, 2011
This Java Class in Android Application Development is to show BT enabling progress

package com.android.bluetooth.opp;

import com.android.bluetooth.R;
import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;

import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

/**
* This class is designed to show BT enabling progress.
*/
public class BluetoothOppBtEnablingActivity extends AlertActivity {
private static final String TAG = "BluetoothOppEnablingActivity";

private static final boolean D = Constants.DEBUG;

private static final boolean V = Constants.VERBOSE;

private static final int BT_ENABLING_TIMEOUT = 0;

private static final int BT_ENABLING_TIMEOUT_VALUE = 20000;

@Override
protected void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);

IntentFilter filter = new IntentFilter(
BluetoothAdapter.ACTION_STATE_CHANGED);
registerReceiver(mBluetoothReceiver, filter);

// Set up the "dialog"
final AlertController.AlertParams p = mAlertParams;
p.mIconId = android.R.drawable.ic_dialog_info;
p.mTitle = getString(R.string.enabling_progress_title);
p.mView = createView();
setupAlert();

// Add timeout for enabling progress
mTimeoutHandler.sendMessageDelayed(mTimeoutHandler
.obtainMessage(BT_ENABLING_TIMEOUT),
BT_ENABLING_TIMEOUT_VALUE);
}

private View createView() {
View view = getLayoutInflater().inflate(
R.layout.bt_enabling_progress, null);
TextView contentView = (TextView) view
.findViewById(R.id.progress_info);
contentView
.setText(getString(R.string.enabling_progress_content));

return view;
}


Read more: nScraps
QR: 1249-java-class-for-bluetooth-bt-enabling.htm

Posted via email from Jasper-net

0 comments: