Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了发送APK文件android大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用此代码将应用程序的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){}

大佬总结

以上是大佬教程为你收集整理的发送APK文件android全部内容,希望文章能够帮你解决发送APK文件android所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。