【发布时间】:2018-06-01 05:47:14
【问题描述】:
检查下面我的代码,。这段代码在我的适配器中。但问题是我的手机完全支持应用和共享,但低版本的手机不支持点击共享时强制关闭。
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String shareBody = "\t\t DIL KI BAAT \n\n" +sayari[position].toString().trim()+"\n\n\n"+ "https://play.google.com/store/apps/details?id="
+ appPackageName;
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
context.startActivity(Intent.createChooser(sharingIntent, context.getResources()
.getString(R.string.app_name)));
}
});
【问题讨论】:
-
发布您的适配器代码
-
我的错误是这样的 android.util.AndroidRuntimeException:从 Activity 上下文之外调用 startActivity() 需要 FLAG_ACTIVITY_NEW_TASK 标志。这真的是你想要的吗?
-
@sasikumar 但是 letest 手机已经在这个代码中工作了,不能在低版本的小型安卓手机上工作?
-
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag您没有尝试在 google 中搜索此错误消息,是吗?
标签: java android android-studio onclick