我尝试了以下应用示例,通过Android Froyo中的蓝牙OPP发送文件。
请提前感谢任何解决方案。
我的应用代码:
public class BtAppExample extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String filePath = Environment.getExternalStorageDirectory().toString() + "/Munnar/1.jpg";
Log.e("BtAppExample","Uri is: "+Uri.fromFile(new File(filePath)).toString());
ContentValues values = new ContentValues();
values.put(BluetoothShare.URI,Uri.fromFile(new File(filePath)).toString());
values.put(BluetoothShare.DESTINATION, "90:4C:E5:D9:0E:D0");
values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);
Long ts = System.currentTimeMillis();
values.put(BluetoothShare.TIMESTAMP, ts);
Uri contentUri = getContentResolver().insert(BluetoothShare.CONTENT_URI, values);
}
}
我的清单文件:
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".BtAppExample"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_BLUETOOTH_SHARE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />