包装我的应用程序,共享给其他的Andr​​oid + [英] packing my app and share to other + android

查看:143
本文介绍了包装我的应用程序,共享给其他的Andr​​oid +的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的Andr​​oid应用程序,我需要一个按钮,我的应用程序发送到另一部手机。

I'm creating an application for android and I need a button to send my application to another phone.

我试图把一个APK发送到其他,但我不能做到这一点。
我使用这个code:

I tried to put an apk and send to other but I can't do it. I'm using this code :

Intent sharei=new Intent(Intent.ACTION_SEND);
sharei.putExtra(Intent.EXTRA_STREAM,Uri.parse("android.resource://com.packa.ge/raw/hafez.apk"));
sharei.setType("application/vnd.android.package-archive");
startActivity(Intent.createChooser(sharei, "share"));

但它不工作。

我看到了波斯的应用程序做到这一点...

i saw an persian app do this ...

在上下文菜单中1个项目是:通过蓝牙发送,当触摸此,apk文件发送给其他手机...

in context menu 1 item was :"Send via Bluetooth" and when touch this , send the apk file to other phone ...!

我收拾我的应用程序,并把它生的文件夹发送,但是这不是为第二或第三的手机正常工作!

i pack My app and put it to Raw folder to send , but this is not work correctly for 2nd or 3rd phone !!

请编写正确的code ...

please write correct code ...

他说:我为Android创建一个应用程序,我需要把按钮,我的应用程序发送到>其他手机,我想他是在谈论他发送运行同一个应用程序....

he said: "i create a application for android i need put button to send my application to >other phone", i think he is talking about sending the same application he is running....

是的,我需要把我的正在运行的应用

yes , i need send my running application

推荐答案

解决...

  try {

PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo(getPackageName(), 0);
File srcFile = new File(ai.publicSourceDir);
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
share.setType("application/vnd.android.package-archive");
share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(srcFile));
startActivity(Intent.createChooser(share, "PersianCoders"));
} catch (Exception e) {
Log.e("ShareApp", e.getMessage());
}

这篇关于包装我的应用程序,共享给其他的Andr​​oid +的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆