I want create activity for share image from drawable source,
and this is my code:
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>
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?!
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.