我在我的应用程序中使用了多个共享意图,但是当我共享并且我的应用程序在后台移动并且共享活动后会破坏时。我试过了:
android:configChanges="orientation|keyboardHidden|screenSize"
和
android:noHistory="true"
针对特定活动并调用明确的意图,例如针对(google+、facebook、twitter 和电子邮件)
startActivityForResult(Intent.createChooser(intent,"Send mail..."),4);
和我的ActivityOnResult
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==FB_SIGN_ING){
callbackManager.onActivityResult(requestCode,resultCode,data);
} //else do nothing
}
更新: 我已经弄清楚当我从背景移到前面时,我的活动会破坏。但是即使我使用特定的配置和ActivityOnResult如何处理它。
意图示例:
public void ShareByEmail(){
final String newsTitle = singleNews.get(0).getNews_title().trim();
String newsPhoto=SingleNewsImages.get(0);
String url = BASE_URL+newsPhoto;
final String newsLink = "http://motorcityarabia.com"+singleNews.get(0).getLink().trim();
final Uri uri = Uri.parse(url);
Target target = new Target() {
@Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
// Intent intent = new Intent(Intent.ACTION_SENDTO,Uri.parse("mailto:"));
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT,newsTitle);
intent.putExtra(Intent.EXTRA_TEXT , Html.fromHtml("<strong><a href='"+newsLink+"'>"+newsTitle+"</a></strong><br/><a href='"+newsLink+"'>READ MORE</a>"));
intent.putExtra(Intent.EXTRA_STREAM, getLocalBitmapUri(bitmap));
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent,"Send mail..."),4);
}
@Override public void onBitmapFailed(Drawable errorDrawable) {
Toast.makeText(SingleNewsActivity.this, "Error Drawable", Toast.LENGTH_SHORT).show();
}
@Override public void onPrepareLoad(Drawable placeHolderDrawable) {
Toast.makeText(SingleNewsActivity.this, "Prepairing Image", Toast.LENGTH_SHORT).show();
}
};
Picasso.with(getApplicationContext()).load(url).into(target);
}