1

overview activity will send and integer to Training activity and training activity will send a feedback to its caller when the activity popped off from stack. so when it returns an integer to overview activity logcat say an error. resource not found

This is OverviewActivity Class

package com.ehsan.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;



public class OverviewActivity extends AppCompatActivity {

    String text = null;
    int skillLevle = 0;
    public static final int REQUEST_CODE = 0;

    private TextView mTextView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_overview);

        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        mTextView = (TextView) findViewById(R.id.username);


        if(intent != null){

            text = bundle.getString("username");

            mTextView.setText(text);


        }
    }

    public void onClick(View view){


        Intent intent = new Intent(this,LearnActivity.class);

        intent.putExtra("skill",skillLevle);

        startActivityForResult(intent,REQUEST_CODE);


    }

    public void onActivityResult(int reqeuestCode,int resutlCode,Intent extras){


        int skills = extras.getIntExtra("skill",0);

        Toast.makeText(this, skills, Toast.LENGTH_LONG).show();


    }
}

and this is LearnActivity Class

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class LearnActivity extends AppCompatActivity {

    private int skillLevle = 5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_learn);

        Intent intent = getIntent();

        if (intent != null){
            skillLevle = intent.getExtras().getInt("skill");
        }
    }

    public void finish(){

        Intent intent2 = new Intent();

        intent2.putExtra("skill",skillLevle);

        setResult(RESULT_OK,intent2);

        super.finish();


    }

}

KUSHA B K
  • 1,489
  • 13
  • 20
Ehsan.sarshar
  • 119
  • 1
  • 1
  • 6

0 Answers0