I am making an android app in which we communicate with arduino but the problem is that when i send character to bluetooth module it show an intent dialog choose option when i select bluetooth its search only mobile devices not bluetooth module???
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT,"b");
intent.setType("text/plain");
startActivity(intent);
PackageManager pm=getPackageManager();
List<ResolveInfo> appslist=pm.queryIntentActivities(intent,0);
if(appslist.size()>0){
String packagename=null;
String classname=null;
boolean found=false;
for(ResolveInfo info:appslist){
packagename=info.activityInfo.packageName;
if(packagename.equals("com.example.app")){
classname=info.activityInfo.name;
found=true;
break;
}
}
if(!found){
showToast("Bluetooth havn't been found");
}else{
intent.setClassName(packagename,classname);
startActivity(intent);
}
}
Aucun commentaire:
Enregistrer un commentaire