views:

39

answers:

1
package supa.mack.doppler;

import java.util.Set;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.bluetooth.*; 
import android.widget.Toast;

public class doppler_test extends Activity {
TextView out;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

out = (TextView) findViewById(R.id.out);

// Getting the Bluetooth adapter
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
out.append("\nAdapter: " + adapter);

// Check for Bluetooth support in the first place 
// Emulator doesn't support Bluetooth and will return null
if(adapter==null) { 
out.append("\nBluetooth NOT supported. Aborting.");
return;
}

// Starting the device discovery
out.append("\nStarting discovery...");
adapter.startDiscovery();
out.append("\nDone with discovery...");

// Listing paired devices
out.append("\nDevices Pared:");
Set<BluetoothDevice> devices = adapter.getBondedDevices();
for (BluetoothDevice device : devices) {
out.append("\nFound device: " + device);
}

Button searchButton=(Button) findViewById(R.id.search_button);
searchButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
Intent intent=new Intent(
doppler_test.this,
search_result.class
);

startActivity(intent);
}
}); 
}
} 

--------------------------------------…

Here is the code where the problem lies....

It doesn't give me an error it says exactly this when I run the android emulator

"[2010-08-25 09:12:42 - doppler_test] ActivityManager: Warning: Activity not started, its current task has been brought to the front"

What I think this means is that the intent of the bluetooth function and the button intent is only operation on a hierarchy system. What I mean by this is that if I were to move the button opperator above the Bluetooth stuff the button will work, but currently when the app is run Bluetooth works but when I press the search button nothing happens.

What else may be helpful is my XML code for the button so here it is......

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.co…
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:background="@color/purple_flurp"…
<TextView 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/hello"/>
<Button
android:id="@+id/search_button"
android:layout_height="wrap_content" 
android:text="@string/search" 
android:layout_width="fill_parent"/>

<TextView 
android:text="@+id/TextView01" 
android:id="@+id/out" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content">
</TextView>
</LinearLayout>

--------------------------------------…

any ideas? Anything would be great! Thanks

A: 

Are you getting the warning when you start the app or when you click the button? If you run an app from eclipse without it having to recompile (ie no code changes), it doesn't go through the uninstall-install process, it just pushes the application to the front just like you would if you resumed it from the phone. It's not an error but a 'working as intended'

Falmarri