Friday, 25 March 2016

setOnClickListener not working android

setOnClickListener was not working when came back to previous activity.
solution what i found is i override the onBackPressed method. i dont relied on default backpress option.

code in first activity
"
closeCameraPreview.setOnClickListener(new View.OnClickListener() {
    @Override    public void onClick(View view) {
        closeCameraPreview.setVisibility(View.INVISIBLE);
        mVideoView.setVisibility(View.INVISIBLE);
        Intent intent = new Intent(view.getContext(), MediaInfoActivity.class);
        String monument = PropertyFile.TargetOne;
        intent.putExtra("monument", monument);
        String monument_images = PropertyFile.TargetOne+"_images";
        intent.putExtra("monument_images",monument_images);
        startActivity(intent);
    }
});

"


code in second activity to come back to first activity.
@Overridepublic void onBackPressed() {
    Intent intent = new Intent(MediaInfoActivity.this, SimpleClientTrackingActivity.class);
    startActivity(intent);
}



i dont know this is the only solution. please comment if you know any alternate solution.
thanks in advance.