bluetooth - Send file to android device 4+ without selection picker -
good morning,
i'm newer in android i'm working on android project send file specific device, got bluetooth device don't need use intent need send selected file device. make research , try use bluetooth share dont work on device 4+ because exception need granturipermission
question how set granturipermission
? there method send items automatically device without user interaction?
here code try :
contentvalues values = new contentvalues(); values.put(bluetoothshare.uri, uri.getpath()); values.put(bluetoothshare.destination, device.getaddress()); values.put(bluetoothshare.direction, bluetoothshare.direction_outbound); long ts = system.currenttimemillis(); values.put(bluetoothshare.timestamp, ts);
i try use intent this
intent sharingintent = new intent(android.content.intent.action_send); sharingintent.putextra(intent.extra_stream, uri); sharingintent.putextra(bluetoothdevice.extra_device, device); packagemanager pm = manager.this.getpackagemanager(); list<resolveinfo> appslist = pm.queryintentactivities( sharingintent, 0); string packagename = ""; string mclassname = ""; if(appslist.size() > 0 ){ for(resolveinfo info: appslist){ packagename = info.activityinfo.packagename; if( packagename.equals("com.android.bluetooth")){ mclassname = info.activityinfo.name; break; } } } sharingintent.setclassname(packagename, classname); sendbroadcast(sharingintent);
but no reaction no exception datas not sent
thank advice
Comments
Post a Comment