Solution: find out which applications support the device for your intention, find the one that is bluetooh, call it directly.
This article answers your question: http://tsicilian.wordpress.com/2012/11/06/bluetooth-data-transfer-with-android/
From the article: We see that the BT application is one of those handlers. We could, of course, let the user select this application from the list and do with it. But if we feel that we should be more convenient for the user, we need to go further and run the application ourselves, and not just display it in the environment of other unnecessary options ... But how?
One way to do this is to use the Androids PackageManager as follows:
//list of apps that can handle our intent PackageManager pm = getPackageManager(); List appsList = pm.queryIntentActivities( intent, 0); if(appsList.size() > 0 { // proceed }
The aforementioned PackageManager method returns a list that we saw earlier of all actions subject to processing file transfer intentions, in the form of a list of ResolveInfo objects that encapsulate the necessary information:
//select bluetooth String packageName = null; String className = null; boolean found = false; for(ResolveInfo info: appsList){ packageName = info.activityInfo.packageName; if( packageName.equals("com.android.bluetooth")){ className = info.activityInfo.name; found = true; break;// found } } if(! found){ Toast.makeText(this, R.string.blu_notfound_inlist, Toast.LENGTH_SHORT).show(); // exit }
Now we have the necessary information to start BT:
//set our intent to launch Bluetooth intent.setClassName(packageName, className); startActivity(intent);
What we have done is to use the package and the corresponding class obtained earlier. Since we are a curious bunch, we may wonder what the class name is for the package "com.android.bluetooth". This is what we would get if we printed it: com.broadcom.bt.app.opp.OppLauncherActivity. OPP stands for Object Push Profile and an Android component that allows you to transfer files wirelessly.
Also in the article how to enable Bluetooth from your application.
Raanan
source share