我在我的应用程序中使用了几个共享意图,但是当我分享并且我的应用程序在后台运行并且在共享活动之后会破坏。 我试过了:
android:configChanges="orientation|keyboardHidden|screenSize"
和
android:noHistory="true"
针对特定活动并调用显式意图,例如(google +,facebook,twitter和email)
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);
}
答案 0 :(得分:0)
在清单中添加以下内容
<application......android:noHistory="false">....</application>