In recent projects, you need to implement the function of transmitting the apk via Bluetooth, which allows you to search for nearby bluetooth mobile phones and share files. From the perspective of demand, the Bluetooth transmission module provided by the android mobile phone can meet the needs, and the implementation is also very simple. However, although Bluetooth modules are usually configured for mainstream models, the fragmentation of android models is too serious, and the Bluetooth functions of mobile phones of different android versions are also different. The versions earlier than 4.0.3 and later use different bluetooth packages: "com. android. bluetooth" and "com. mediatek. bluetooth ". Some manufacturers also customize and modify the bluetooth module, such as Huawei's c8812. In addition, the android Bluetooth function is available only after api5, so the minSdkVersion of android is no less than 5. There are a lot of examples on the Internet for android to call the Bluetooth sending module. There are few examples that are complete and compatible with multiple systems. Here is an example of my project. /*** Send a file via Bluetooth */private void sendFile (Activity activity) {PackageManager localPackageManager = activity. getPackageManager (); Intent localIntent = null; HashMap <String, ActivityInfo> localHashMap = null; try {localIntent = new Intent (); localIntent. setAction (Intent. ACTION_SEND); File file = new File (TAExternalOverFroyoUtils. getDiskCacheDir (this, Constants. DOWNLOAD_DIR ). getAbsolutePath (), TextUt Ils. genApkName (worm. getWormid (); localIntent. putExtra (Intent. EXTRA_STREAM, Uri. fromFile (file); // localIntent. putExtra (Intent. EXTRA_STREAM, // Uri. fromFile (new File (localApplicationInfo. sourceDir); localIntent. setType ("*/*"); List <ResolveInfo> localList = localPackageManager. queryIntentActivities (localIntent, 0); localHashMap = new HashMap <String, ActivityInfo> (); Iterator <ResolveInfo> local Iterator1 = localList. iterator (); while (localIterator1.hasNext () {ResolveInfo resolveInfo = (ResolveInfo) localIterator1.next (); ActivityInfo localActivityInfo2 = resolveInfo. activityInfo; String str = localActivityInfo2.applicationInfo. processName; if (str. contains ("bluetooth") localHashMap. put (str, localActivityInfo2);} catch (Exception localException) {ToastHelper. showBlueToothSupportEr R (activity);} if (localHashMap. size () = 0) ToastHelper. showdomainthsupporterr (activity); ActivityInfo localActivityInfo1 = (ActivityInfo) localHashMap. get ("com. android. bluetooth "); if (localActivityInfo1 = null) {localActivityInfo1 = (ActivityInfo) localHashMap. get ("com. mediatek. bluetooth ");} if (localActivityInfo1 = null) {Iterator <ActivityInfo> localIterator2 = localHashMap. values (). it Erator (); if (localIterator2.hasNext () localActivityInfo1 = (ActivityInfo) localIterator2.next ();} if (localActivityInfo1! = Null) {localIntent. setComponent (new ComponentName (component, localActivityInfo1.name); activity. startActivityForResult (localIntent, 4098); return;} ToastHelper. show1_thsupporterr (activity);} effect: