Is it possible to detect if an ACTION_SEND Intent suceeded?

前端 未结 2 1708
广开言路
广开言路 2021-01-19 03:20

I have a simple Android app with code like this (from the Android Documentation):

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);         


        
2条回答
  •  清歌不尽
    2021-01-19 03:30

    I don't think there is an assured way to do it.

    You could initiate the send using startActivityForResult() and hope that the activity which handles the Intent replies with a RESULT_OK. But you can't rely on it to work always.

    AnD then you can check

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            Toast.makeText(this,"Successfully Sharing", Toast.LENGTH_SHORT).show();
    
        }
    }
    

提交回复
热议问题