2017-08-03 173 views
0

你好,我是新来的Android工作室我已经建立了一个应用程序时,你从相机应用中的照片看到它在一个ImageView的和共享份额从相机拍摄到的图像视图图像

我已经做了分享按钮:

case R.id.shrbtn: 
    startshare(); 
    break; 

共享按钮去这个方法开始共享照片 我已经加入网络的权限和按钮没有做任何事情:

private void startshare() { 
    Bitmap bmp=viewToBitmap(Image,Image.getWidth(),Image.getHeight()); 
    Intent shareIntent = new Intent(Intent.ACTION_SEND); 
    shareIntent.setType("image/*"); 
    Uri phototUri = Uri.parse(String.valueOf(Bitmap.createBitmap(bmp))); 
    shareIntent.setData(phototUri); 
    shareIntent.putExtra(shareIntent.EXTRA_STREAM,phototUri); 
    startActivity(Intent.createChooser(shareIntent, "Share Via")); 
} 

谁能告诉我什么是缺失?

回答

1

发送它的意图,并从startActivityForResult()方法得到它。

This教程解释得很好

+0

我已经有一个方法,但是对于图像设置为墙纸保护无效onActivityResult(INT requestCode,诠释resultCode为按钮,意图数据){ super.onActivityResult(requestCode,resultCode,data); if(resultCode == RESULT_OK){ Bundle extras = data.getExtras(); bmp =(位图)extras.get(“data”); Image.setImageBitmap(bmp); } – Hesham

0

这听起来好像有关按钮回调本身的问题。你确定该方法已被调用?也许你应该设置断点来确定问题?

也许你应该看看这里(如您的共享意图看起来是错误的):https://stackoverflow.com/a/7662164/6268503

+0

我忘了设置setOnClickListener我设置它测试我的平板电脑上的应用程序,并弹出显示与这个没有应用程序可以执行此操作这里是我的代码再次Bitmap bmp = viewToBitmap(Image,Image.getWidth(),Image .getHeight()); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType(“image/*”); Uri phototUri = Uri.parse(String.valueOf(Bitmap.createBitmap(bmp))); shareIntent.setData(phototUri); shareIntent.putExtra(shareIntent.EXTRA_STREAM,phototUri); startActivity(Intent.createChooser(shareIntent,“Share Via”)); – Hesham

相关问题