package org.arsenaultmarc45.polarheartmonitor;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import android.app.Activity;
import android.app.ActionBar;
import android.app.AlertDialog;
import android.app.Fragment;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.os.Build;

public class MainActivity extends Activity  implements OnItemSelectedListener {
	
	int i =0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		if (savedInstanceState == null) {
			getFragmentManager().beginTransaction()
					.add(R.id.container, new PlaceholderFragment()).commit();
		}

	}
	
	public void onStart(){
		super.onStart();
		
		//Discover bluetooth devices
		List<String> list = new ArrayList<String>();
		BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
		Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
		// If there are paired devices
		if (pairedDevices.size() > 0) {
		    // Loop through paired devices
		    for (BluetoothDevice device : pairedDevices) {
		        // Add the name and address to an array adapter to show in a ListView
		        list.add(device.getName() + "\n" + device.getAddress());
		    }
		}
		
		
		//Populate drop down
		Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
				ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
			android.R.layout.simple_spinner_item, list);
		dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner1.setOnItemSelectedListener(this);
		spinner1.setAdapter(dataAdapter);
	}

	
	/**
	 * A placeholder fragment containing a simple view.
	 */
	public static class PlaceholderFragment extends Fragment {

		public PlaceholderFragment() {
		}

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			View rootView = inflater.inflate(R.layout.fragment_main,
					container, false);
			return rootView;
		}
	}


	@Override
	public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
			long arg3) {
		//ID est celui en ordre
		
	}

	@Override
	public void onNothingSelected(AdapterView<?> arg0) {

		
	}

}

@@ -155,72 +155,8 @@
 y;%0D%0A
-import android.app.ActionBar;%0D%0Aimport android.app.AlertDialog;%0D%0A
 impo
@@ -177,24 +177,24 @@
 .Fragment;%0D%0A
+
 import andro
@@ -272,49 +272,8 @@
 e;%0D%0A
-import android.content.DialogInterface;%0D%0A
 impo
@@ -336,66 +336,8 @@
 r;%0D%0A
-import android.view.Menu;%0D%0Aimport android.view.MenuItem;%0D%0A
 impo
@@ -559,67 +559,124 @@
 r;%0D%0A
-import android.widget.TextView;%0D%0Aimp
+%0D%0A%0D%0A/**%0D%0A * This program connect to a bluetooth polar heart rate monit
 or
-t
  and
-roid.os.Build;%0D%0A
+ display data%0D%0A * @author Marco%0D%0A *%0D%0A */
 %0D%0Apu

add comments