开发者

onActivityResult does not get data on Android 1.6

开发者 https://www.devze.com 2023-03-11 11:15 出处:网络
I have two Activites. Activity B will get called by Activity A like this: p开发者_运维知识库ublic void onClick(View v) {

I have two Activites. Activity B will get called by Activity A like this:

p开发者_运维知识库ublic void onClick(View v) {
    Intent i = new Intent(SearchViewLevel2.this, SearchViewLevel3.class);
    startActivityForResult(i, 7788);
}

In Activity B in onCreate() I have setResult(Activity.RESULT_OK, inti). Then I override the BackButton:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    super.onKeyDown(keyCode, event);
mcontext = getBaseContext();
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if(fa.getCheckedPositions().size() > 0) {
            checked = true;
        }
        inti.putExtra("data", checked);
        inti.putExtra("mypos", thispos);
        return true;
    }
    return false;
}

In Activity A I have onActivityResult() like that:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    mContext = getBaseContext();
    if (requestCode == 7788) {
        if (resultCode == Activity.RESULT_OK) { //until here it comes
            boolean l = data.getBooleanExtra("data", false); 
            // in 1.6 the boolean is false, so it doesn't get any data
            if (l) { 
                CheckBox cb =
                    (CheckBox)fa.getViewAtIndex(
                        data.getIntExtra("mypos", -1)).findViewById(10110);
                cb.setBackgroundResource(R.drawable.selectionpartial);
            }       
        } 
    } 
}

My problem is that I don't get any data in Android 1.6, but in higher Versions I do.

So are there any differences beetween 1.6 and higher Versions in this code?

0

精彩评论

暂无评论...
验证码 换一张
取 消