<activity android:excludeFromRecents="true" android:name="ReceiveOpenActivity">
<intent-filter android:label="转换为分享文件">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="*/*"/>
</intent-filter>
</activity>
public class ReceiveOpenActivity extends Activity {
@Override
protected void onDestroy() {
super.onDestroy();
finishAffinity();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
finish();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
builder.detectFileUriExposure();
setContentView(R.layout.activity_receive_open);
Intent intent = new Intent();
intent.setAction("android.intent.action.SEND");
intent.addFlags(268435456);
intent.addCategory("android.intent.category.DEFAULT");
intent.putExtra("android.intent.extra.STREAM", (Parcelable)getIntent().getData());
intent.setType(getIntent().getType());
startActivityForResult(Intent.createChooser(intent, "), 1);
finish();
}
}