开发者

ActivityManager: Warning: Activity not started, its current task has been brought to the front

开发者 https://www.devze.com 2023-01-13 16:58 出处:网络
package supa.mack.doppler; import java.util.Set; import android.app.Activity; import android.content.Intent;
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


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'


thats problem is obvious on eclipse with adt plugin. Main problem is ... your application was started on emulator/device and now you try start it again without any changes on source codes. Possible solutions : 1 rebuild project and start app again (its take more time) 2 add some space/new line to code and start app again

I prefer second options coz its very fast. But IMHO i think its stupid problem on side plugin's developers


In my case the problem was the bad configuration of my HTC connected to PC. Try to run the emulator with the phone disconnected-


It's posible, in case, if yours AVD is started and Locked. You need unlock AVD display.


This means that the app which you try to deply in emulator and already existing same app in emulator are same. There is no change in both of them..

Still you get error then Project -> Clean from eclipse and restart avd and deply again..


If you get this warning it means you haven't changed any line of your code and this instance of your project is running on emulator or on your device. So if you want to run that again you can:

1- Make some changes in your code and then compile it again.

2- Or you can easily close the app and then relaunch it with eclipse or android studio or ...

If the problem still persist try to uninstall the app and run it again.

0

精彩评论

暂无评论...
验证码 换一张
取 消