安卓系统:使用蓝牙或电子邮件传输图像



我是Android开发的新手。我正在尝试制作一个应用程序,加载图像,编辑和保存它,并通过蓝牙和电子邮件传输图像。

Android似乎有一个内置的工具,我可以使用它来轻松实现蓝牙功能,但我还找不到任何简单直接的教程。

有人能帮我,给我一个关于蓝牙功能或电子邮件功能的好教程的例子或链接吗?

请帮忙!

感谢

使用以下脚本

Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("image/jpeg");
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Photo");
        sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/dcim/Camera/filename.jpg"));
        sendIntent.putExtra(Intent.EXTRA_TEXT, "Enjoy the photo");
        startActivity(Intent.createChooser(sendIntent, "Email:"));

使用此代码,首先将文件保存在sdCad上,然后用Bt、电子邮件或。。。

    send.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View arg0) {
        File newSoundFile = new File("/sdcard/101Ringtone.ogg");
        Uri mUri = Uri.parse("android.resource://" + getPackageName() + "/"+ RingtoneRaw);
        ContentResolver mCr = getContentResolver();
        AssetFileDescriptor soundFile;
        try {
            soundFile= mCr.openAssetFileDescriptor(mUri, "r");
           } catch (FileNotFoundException e) {
               soundFile=null;   
           }
           try {
              byte[] readData = new byte[1024];
              FileInputStream fis = soundFile.createInputStream();
              FileOutputStream fos = new FileOutputStream(newSoundFile);
              int i = fis.read(readData);
              while (i != -1) {
                fos.write(readData, 0, i);
                i = fis.read(readData);
              }
              fos.close();
           } catch (IOException io) {
           }
        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("audio/ogg");    
        i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(newSoundFile)); 
        startActivity(Intent.createChooser(i, "Share ringtone via:"));
    }
});

最新更新