android - 发送 APK 文件 android

标签 android bluetooth apk

我使用此代码将应用的 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/

相关文章:

android - 使用从 Google Play 下载的证书对 APK 进行签名

java - 调用performClick()函数时什么也没得到 - Android

android - 何时取消注册 LocalBroadcastManager 接收器?

android - 如何在一个脚本上为两种操作系统(Android 和 IOS)创建驱动程序

iphone - 在iPhone上实现蓝牙数据传输

android - 将 Android 应用程序从一个设备复制到另一个设备是否也会复制数据?

java - 在android中创建类似glide和picasso的类结构

javascript - 在没有互联网连接的情况下,WebRTC 是否支持点对点连接?

ios - ios safari 可以访问蓝牙设备吗?

android - 与不同的开发人员一起更新现有的调试应用程序