Android ActivityManager: 警告: Activity 未启动,其当前任务已被置于最前面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3569315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:47:28  来源:igfitidea点击:

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

androideclipsebluetooth

提问by David

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

它没有给我一个错误,它在我运行 android 模拟器时准确地说明了这一点

"[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 代码,所以这里是......

<?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

有任何想法吗?任何事情都会很棒!谢谢

回答by Falmarri

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'

当您启动应用程序或单击按钮时,您是否收到警告?如果您从 Eclipse 运行应用程序而无需重新编译(即不更改代码),它不会通过卸载-安装过程,它只是将应用程序推送到前面,就像您从手机恢复它一样. 这不是错误,而是“按预期工作”

回答by Rob

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

这个问题在带有adt插件的eclipse上很明显。主要问题是……您的应用程序是在模拟器/设备上启动的,现在您尝试重新启动它,而无需更改源代码。可能的解决方案:1 重建项目并再次启动应用程序(需要更多时间) 2 添加一些空格/新行代码并再次启动应用程序

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

我更喜欢第二种选择,因为它非常快。但恕我直言,我认为插件开发人员的愚蠢问题

回答by Cybergnomo

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

就我而言,问题是我的 HTC 连接到 PC 的配置错误。尝试在手机断开连接的情况下运行模拟器-

回答by Pradip Bhatt

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..

仍然出现错误,然后 Project -> Clean from eclipse 并重新启动 avd 并再次部署..

回答by Sejton

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

如果您的 AVD 已启动并已锁定,这是可能的。您需要解锁 AVD 显示。

回答by Milad Faridnia

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.

1- 对代码进行一些更改,然后再次编译。

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

2- 或者您可以轻松关闭应用程序,然后使用 eclipse 或 android studio 或...

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

如果问题仍然存在,请尝试卸载该应用程序并再次运行。