-1

My class activity should return callback interface to other class
step1. class 1 open Activity
step2. Activity return callback to class1

Can i do somthing like that?

AccountPickerActivity pickerActivity = new AccountPickerActivity(new AccountPickerActivity.onPickAccountFromPickerIntent() {
    @Override
    public void onPickAccountFromPickerIntent() {
                onConnected(null);

    }
});
Intent i = new Intent(mContext, pickerActivity.getClass());
mContext.startActivity(i);

Or there is any way to call interface from activity to other class (witout using static)?

Anna
  • 499
  • 1
  • 6
  • 24
  • Not possible the way you are doing it. Read this http://developer.android.com/training/basics/intents/result.html – Rohit5k2 Feb 03 '16 at 14:00
  • And this too http://stackoverflow.com/questions/7262405/handling-onactivityresult-in-android-app-having-more-than-one-activity – Rohit5k2 Feb 03 '16 at 14:01
  • I know that but the class that open the activity is not activity, you think i need to get the activity result from the root Activity? – Anna Feb 03 '16 at 14:02
  • you may need to restructure the logic you are working on to avoid this situation, because proper way is to open activity for result,and read results with onactivityresult... – Yazan Feb 03 '16 at 14:13

1 Answers1

0

You should use startActivityForResult() for starting Activity2 from Activity1. You can setResults from Activity2 and when it gets back to Activity1 the overriden method onActivityResult(int requestCode, int resultCode, Intent data) {//} can receive the results.

Read in detail : Getting a Result from an Activity

Tafveez Mehdi
  • 456
  • 3
  • 12