Newbie here. I have an app I'm working on that is all image views and everything is running fine but the problem I have is that I can't seem to open an image in email or attach an email in text msg as they both state, using the share intent method. It will show the text I attach and it sends just fine but with the images I can't open or attach them. I have added the write_external method as well in manifest. Hope someone can help me fix this. Code is below, but the share intent section is a little messy as I have 2 diff codes in there for running share intent with image..both work fine..no errors...but neither open or attach image via text or email.
package com.app.appname;
import android.app.ActionBar;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Spannable;
import android.text.SpannableString;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdRequest.Builder;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import java.io.File;
import static com.app.appname.R.id.adView;
public class imageView1 extends AppCompatActivity {
private ImageView imgview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.imageview1);
SpannableString s = new SpannableString("Action Bar Title");
s.setSpan(new TypefaceSpan(this, "Sui.ttf"), 0, s.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// Update the action bar title with the TypefaceSpan instance
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(s);
AdView mAdView = (AdView) findViewById(adView);
AdRequest adRequest = new AdRequest.Builder()
.build();
mAdView.loadAd(adRequest); }
public void shareText(View view) {
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.setType("image/jpeg");
String shareBodyText = "Sharing message goes here";
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject/Title");
intent.putExtra(android.content.Intent.EXTRA_TEXT, shareBodyText);
startActivity(Intent.createChooser(intent, "Choose sharing method"));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.action_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.share:
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
Uri imageUri = Uri.parse("android.resource://com.app.appname/pic1.jpg");
Log.i("imageUri",""+imageUri);
share.putExtra(Intent.EXTRA_STREAM,imageUri);
startActivity(Intent.createChooser(share, "Share Image"));
Uri u = Uri.parse("android.resource://com.app.appname/pic1.jpg");
File f = new File("" + u);
f.getName();
sharingIntent.setType("image/jpeg");
Uri uri = Uri.parse("android.resource://com.app.appname/"+R.drawable.pic1);
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
String shareBodyText = "Download app from ";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "App Name");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBodyText);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}