2010-08-25 48 views
37
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); 
} 
}); 
} 
} 

--------------------------- ----------- ...ActivityManager:警告:活動未啓動,其當前任務已提前

這是問題所在的代碼....

它不給我它到底說這樣的一個錯誤,當我運行Android模擬器

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

我認爲這意味着藍牙功能的意圖和按鈕意圖只是操作o一個分級系統。我的意思是,如果我要將按鈕操作器移動到藍牙以上,按鈕將起作用,但是當前應用程序運行時藍牙工作正常,但是當我按下搜索按鈕時,什麼都不會發生。

還有什麼可能是有益的是按鈕我的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> 

----------------- --------------------- ...

有什麼想法嗎? 任何事情都會很棒! 謝謝

回答

56

您是否在啓動應用程序或單擊按鈕時收到警告?如果你從eclipse運行一個應用程序而不需要重新編譯(即沒有代碼改變),它不會經過卸載 - 安裝過程,它只是將應用程序推到前面,就像你從電話中恢復應用程序一樣。這不是一個錯誤,但一個'按預期工作'

+30

添加到Falmari @ David只是做一個Project> Clean來重新編譯項目 – 100rabh 2011-01-20 05:28:13

+0

我有一個與ant目標的一些strings.xml文件相同的問題,我想也許它會刷新項目(F5)然後在設備/模擬器:) thx中啓動應用程序以獲取答案 – 2013-10-18 12:56:41

2

這是可能的,以防萬一,如果你的AVD啓動和鎖定。您需要解鎖AVD顯示器。

23

多數民衆贊成在日食與adt插件問題是顯而易見的。主要問題是...你的應用程序是在仿真器/設備上啓動的,現在你可以嘗試再次啓動它,而無需對源代碼進行任何更改。 可能的解決方案: 1改造項目,然後重新啓動應用程序(它需要更多的時間) 2添加一些空間/新行代碼,並再次啓動應用

我更喜歡第二個選項怎麼把它非常快。但恕我直言,我認爲它的愚蠢的問題側插件的開發者

3

在我的情況下,問題是我的HTC連接到PC的配置不好。嘗試運行與電話斷開連接的模擬器 -

2

這意味着您嘗試在模擬器中deply的應用程序和模擬器中已存在的相同應用程序是相同的。有一個在他們兩人沒有變化..

你仍然得到錯誤,那麼項目 - >從日食清理並重新啓動AVD和deply再次..

1

如果你得到這樣的警告就意味着你沒有任何改變你的代碼行和你的項目的這個實例運行在模擬器或你的設備上。所以,如果你想再次運行,你可以:

1-在你的代碼中做一些改變,然後再編譯一遍。

2-或者您可以輕鬆關閉應用程序,然後使用eclipse或android studio重新啓動它或...

如果問題仍然存在,請嘗試卸載應用程序並重新運行。

相關問題