我使用此代码将应用程序的APK文件发送到另一台设备.它适用于
android 2.3.3,但不适用于android 4.
问题出在哪儿?
我已经记录了getpackageCodePath(),它在android 4上返回了APK文件,但是整个代码都没有工作,当蓝牙启动时,它什么也没发送.
- ArrayList<Uri> uris = new ArrayList<Uri>();
- Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
- sendIntent.setType("application/vnd.android.package-archive");
- uris.add(Uri.parse(getApplication().getPackageCodePath()));
- sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);
- startActivity(Intent.createChooser(sendIntent,null));
解决方法
我使用下面的代码发送apk.它的工作原理
- try{
- ArrayList<Uri> uris = new ArrayList<Uri>();
- Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
- sendIntent.setType("application/*");
- uris.add(Uri.fromFile(new File(getApplicationInfo().publicSourceDir)));
- sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);
- startActivity(Intent.createChooser(sendIntent,null));
- }catch(Exception e){}