How to get Result data from android native calculator

馋奶兔 提交于 2019-12-12 03:48:26

问题


I'm invoking android native calculator from my app, how do i get result data from it.. means i started native calender like this, after finishing calculation i press back onActivityResult is not executing.. Help me

 Intent i = new Intent();
 i.setClassName("com.android.calculator2",
                "com.android.calculator2.Calculator");
 startActivityForResult(i, 1); 

  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if(requestCode == 1){
        Log.i("CALCULATOR", "Result Data is"+ data);
    }       
}

回答1:


Start it:

Intent i = new Intent();
i.setClassName("com.android.calculator2",
"com.android.calculator2.Calculator");

Then the Calculator Acitivity should use
setResult(RESULT_SUCESS, simple_intent_with_result_as_extra)

When the Calculator Activity Exits, the onActivityResult will be called on your original Activity with that Intent you passed earlier.



来源:https://stackoverflow.com/questions/10553893/how-to-get-result-data-from-android-native-calculator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!