ورود

View Full Version : مشکل در کد اشتراک نرم افزار با بلوتوث



Aram0630
پنج شنبه 30 بهمن 1393, 20:00 عصر
سلام دوستان
من تو نرم افزارم یه imageButton گذاشتم که وقتی کاربر روش کلیک میکنه بتونه نرم افزار رو با بلوتوث بفرسته .
این کد هامه . میشه ببینین مشکل از کجاست ؟

package com.aram0630.azmayesh;
import java.io.File;


import android.app.Activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;


public class Share extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.share);

ImageButton imgbtn1=(ImageButton) findViewById(R.id.imageButton1);
imgbtn1.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) {
// TODO Auto-generated method stub
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());
}

}

اینم سکرین شات واسه اینکه بدونین کجاش ارور میده .


http://dl.darya-gsm.com/images/ppmyfld6wfh527su9ktp_thumb.jpg (http://dl.darya-gsm.com/viewer.php?file=ppmyfld6wfh527su9ktp.jpg)

yasinf
پنج شنبه 30 بهمن 1393, 21:11 عصر
public class G extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.share);


ImageButton imgbtn1=(ImageButton) findViewById(R.id.imageButton1);
imgbtn1.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
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());}
}});
}
}

Aram0630
پنج شنبه 30 بهمن 1393, 21:48 عصر
ممنون از لطفتون حل شد .
اگه میشه برچسب حل شد به عنوان تاپیک هم اضافه کنین .