1.分享功能简单实现。
shareBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent localIntent = new Intent("android.intent.action.SEND");
localIntent.setType("text/plain");
String str = "这个是我的分享内容你看看。";
localIntent.putExtra("android.intent.extra.TEXT", str
+ "#aaa#");
localIntent.setFlags(268435456);//
MainActivity.this.startActivity(Intent.createChooser(
localIntent, "测试文字"));
}
});
很多人使用startActivity时候,会碰到如下的异常:
Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
都知道,Context中有一个startActivity方法&#x