hamedh.1990 hamedh.1990 - 1 year ago 85
Android Question

packing my app and share to other + android

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

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);
startActivity(Intent.createChooser(sharei, "share"));

but it isn't working.

i saw an persian app do this ...

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 !!

please write correct code ...

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....

Andrea Bellitto

yes , i need send my running application

Answer Source

resolved ...

try {
    PackageManager pm = getPackageManager();
    ApplicationInfo ai = pm.getApplicationInfo(getPackageName(), 0);
    File srcFile = new File(ai.publicSourceDir);
    Intent share = new Intent();
    share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(srcFile));
    startActivity(Intent.createChooser(share, "PersianCoders"));
} catch (Exception e) {
    Log.e("ShareApp", e.getMessage());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download