obsidian/笔记文件/2.笔记/onActivityResult.md
2025-03-26 00:02:56 +08:00

1.0 KiB
Raw Permalink Blame History

#安卓

新建一个Activity活动类继承自Activity

!Pasted image 20241115095200.png

然后,可以 Override 一个 onActivityResult 接收回调的相关逻辑:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
        //This is where you consume the respondent data returned by the SurveyMonkey Mobile Feedback SDK
        //In this example, we deserialize the user's response, check to see if they gave our app 4 or 5 stars, and then provide visual prompts to the user based on their response
        super.onActivityResult(requestCode, resultCode, intent);
        if (resultCode == RESULT_OK) {
            String respondent = intent.getStringExtra(SM_RESPONDENT);
        } else {
            SMError e = (SMError) intent.getSerializableExtra(SM_ERROR);
            Log.d("SM-ERROR", e.getDescription());
        }
        
        finish();
    }

其中finish指的是,接收到消息后,完成结束 该Activity 的生命周期