我使用此代码将应用的 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){}
关于android - 发送 APK 文件 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17391591/