从drawable共享图像 [英] sharing image from drawable
本文介绍了从drawable共享图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从可绘制源创建共享图像的活动,
I want create activity for share image from drawable source,
这是我的代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Uri imageUri = Uri.parse("android.resource://com.androidbegin.shareimagetutorial/drawable"+R.drawable.ic_launcher);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(intent , "Share"));
}
});
这是我的清单应用程序:
and this is my manifest app:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidbegin.shareimagetutorial"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:uiOptions="splitActionBarWhenNarrow" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
但是,当我启动应用程序时在接下来的7年中,我选择了蓝牙,
我得到了找不到未知文件吐司消息!
but , when i launch app in nexts 7 ,and i select bluetooth ,
i get the unkown file not found toast message!!
可以任何机构帮助这个问题是什么?!
can any body help what is this problem?!
推荐答案
您要共享可绘制资源中的图像。但是其他应用程序无法访问您的资源。有两种解决方法。 1.使用内容提供商。 2.首先将文件复制到外部/公共内存。
You want to share an image from drawable resource. But other apps have no access to your resources. There are two ways to solve this. 1. Use a content provider. 2. Copy the file to external/public memory first.
这篇关于从drawable共享图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文