1
我在藍牙文件或消息傳輸過程中遇到應用程序加載問題。藍牙文件或消息傳輸
我的代碼如下
final ArrayList<String> todoItems = new ArrayList<String>();
mArrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,todoItems);
Button btnClick;
BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();
if(bluetooth != null)
{
// Continue with bluetooth setup.
}
if (bluetooth.isEnabled()) {
// Enabled. Work with Bluetooth.
}
else
{
// Disabled. Do something else.
}
String mydeviceaddress = "";
String mydeviceaddress1 = "";
String mydevicename = "";
Set<BluetoothDevice> pairedDevices;
BluetoothDevice[] pairedDevicesArray;
String status = "";
String FnlDeviceAdd = "";
if (bluetooth.isEnabled())
{
try
{
pairedDevices = bluetooth.getBondedDevices();
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
mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
FnlDeviceAdd =device.getAddress();
status = mydevicename + " : " + mydeviceaddress + " : " + bluetooth.getState();
//String filePath = Environment.getExternalStorageDirectory().toString() + "/Munnar/1.jpg";
String filePath = Environment.getRootDirectory()+ "/devicefriendlyname.txt";
ContentValues values = new ContentValues();
values.put(BluetoothShare.URI, "hello");
//values.put(BluetoothShare.DESTINATION, FnlDeviceAdd);
values.put(BluetoothShare.URI,Uri.fromFile(new File(filePath)).toString());
Toast.makeText(this, "mydeviceaddress "+mydeviceaddress, Toast.LENGTH_LONG).show();
values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);
Long ts = System.currentTimeMillis();
values.put(BluetoothShare.TIMESTAMP, ts);
Uri contentUri = getContentResolver().insert(BluetoothShare.CONTENT_URI, values);
}
}
}
catch(Exception ex)
{
}
}
else
{
status = "Bluetooth is not Enabled.";
}
我的日誌貓詳情如下
04-29 17:20:26.850: E/ThrottleService(520): Could not open GPS configuration file /etc/gps.conf
04-29 17:20:44.930: E/ActivityManager(520): ANR in com.amazon.venezia
04-29 17:20:44.930: E/ActivityManager(520): Reason: Broadcast of Intent { act=android.net.conn.CONNECTIVITY_CHANGE cmp=com.amazon.venezia/.notification.ClientBroadcastReceiver (has extras) }
04-29 17:20:44.930: E/ActivityManager(520): Load: 5.57/1.87/0.66
04-29 17:20:44.930: E/ActivityManager(520): CPU usage from 6290ms to 0ms ago:
04-29 17:20:44.930: E/ActivityManager(520): 4.4% 682/com.amazon.venezia: 3.9% user + 0.4% kernel/faults: 2772 minor 23 major
04-29 17:20:44.930: E/ActivityManager(520): 1.1% 520/system_server: 0.9% user + 0.1% kernel/faults: 273 minor
04-29 17:20:44.930: E/ActivityManager(520): 0.6% 690/com.bluestacks.home: 0.4% user + 0.1% kernel/faults: 1551 minor 2 major
04-29 17:20:44.930: E/ActivityManager(520): 0.4% 338/bstblock: 0% user + 0.4% kernel
04-29 17:20:44.930: E/ActivityManager(520): 0% 412/loop1: 0% user + 0% kernel
04-29 17:20:44.930: E/ActivityManager(520): 0.1% 490/zygote: 0% user + 0.1% kernel/faults: 8 minor
04-29 17:20:44.930: E/ActivityManager(520): 0.1% 608/com.android.systemui: 0.1% user + 0% kernel/faults: 82 minor
04-29 17:20:44.930: E/ActivityManager(520): 0.1% 666/com.google.process.gapps: 0.1% user + 0% kernel/faults: 110 minor
04-29 17:20:44.930: E/ActivityManager(520): +0% 737/zygote: 0% user + 0% kernel
04-29 17:20:44.930: E/ActivityManager(520): 95% TOTAL: 6.5% user + 2.8% kernel + 86% iowait
04-29 17:20:44.930: E/ActivityManager(520): CPU usage from 160ms to 670ms later:
04-29 17:20:44.930: E/ActivityManager(520): 16% 737/com.facebook.katana: 15% user + 1.6% kernel/faults: 1142 minor 3 major
04-29 17:20:44.930: E/ActivityManager(520): 8.4% 737/re-initialized>: 8.4% user + 0% kernel
04-29 17:20:44.930: E/ActivityManager(520): 6.7% 739/GC: 6.7% user + 0% kernel
04-29 17:20:44.930: E/ActivityManager(520): 1.6% 738/HeapWorker: 0% user + 1.6% kernel
04-29 17:20:44.930: E/ActivityManager(520): 5% 682/com.amazon.venezia: 5% user + 0% kernel/faults: 157 minor
04-29 17:20:44.930: E/ActivityManager(520): 5% 682/.amazon.venezia: 5% user + 0% kernel
04-29 17:20:44.930: E/ActivityManager(520): +0% 744/[email protected]: 0% user + 0% kernel
04-29 17:20:44.930: E/ActivityManager(520): 3.9% 520/system_server: 0% user + 3.9% kernel/faults: 1170 minor
04-29 17:20:44.930: E/ActivityManager(520): 3.9% 525/Binder Thread #: 0% user + 3.9% kernel
04-29 17:20:44.930: E/ActivityManager(520): 82% TOTAL: 23% user + 5.8% kernel + 52% iowait
04-29 17:35:57.850: E/PGA(520): PgaSocketWriteAllHdipc: hd_ipc_send() failed
04-29 17:35:57.850: E/PGA(520): PgaSocketWriteAllHdipc: hd_ipc_send() failed
04-29 17:35:59.060: E/PGA(520): PgaSocketWriteAllHdipc: hd_ipc_send() failed
04-29 17:35:59.060: E/PGA(520): PgaSocketWriteAllHdipc: hd_ipc_send() failed
04-29 17:35:59.060: E/PGA(520): PgaSocketWriteAllHdipc: hd_ipc_send() failed
04-29 17:35:59.060: E/PGA(520): PgaSocketWriteAllHdipc: hd_ipc_send() failed
04-29 17:35:59.060: E/PGA(520): PgaSocketWriteAllHdipc: hd_ipc_send() failed
04-29 17:35:59.060: E/PGA(520): PgaSocketWriteAllHdipc: hd_ipc_send() failed
其他藍牙設備無法接收文件
任何人可以幫助我解決這個問題? 任何機構可以告訴我我的文件或消息傳輸錯誤?
改變了我這樣的代碼來發送文件,但不能得逞
`ContentValues values = new ContentValues();
values.put(BluetoothShare.URI,Uri.fromFile(new File(filePath1)).toString());
values.put(BluetoothShare.DESTINATION, FnlDeviceAdd);
values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);
Long ts = System.currentTimeMillis();
values.put(BluetoothShare.TIMESTAMP, ts);
Integer records = null;
if (Strput.length() != 0) {
records = Integer.parseInt(Strput.toString().trim();
}
if (records == null) {
records = 1;
}
for (int i = 0; i < records; i++) {
Uri contentUri = getContentResolver().insert(BluetoothShare.CONTENT_URI, values);
currentInsert = contentUri.getPathSegments().get(1);
`
我需要使用BluetoothSocket和BluetoothServerSocket滿足我的文件傳輸的目的嗎? – Dipali 2013-05-01 05:09:20