Search code examples
androidonactivityresultneura

Not receiving onActivityResult when finish authenticate with Neura


I'm using Neura sdk in order to detect when i arrive and leave home.

My application sends feedback to the user's selected contacts when he arrives and leaves home. I've initiated connection with neura api, as declared in their documentations, and called authenticate. However, when authenticating with neura(basically, did a login), I'm not receiving the response onActivityResult.

Here's my code : public class MainActivity extends AppCompatActivity {

private static final int NEURA_AUTHENTICATION_REQUEST_CODE = 100;
private NeuraApiClient mNeuraApiClient;
private ArrayList<Permission> mPermissions;

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

    Builder builder = new Builder(this);
    mNeuraApiClient = builder.build();
    mNeuraApiClient.setAppUid(getResources().getString(R.string.app_uid));
    mNeuraApiClient.setAppSecret(getResources().getString(R.string.app_secret));
    mNeuraApiClient.connect();

    mPermissions = Permission.list(new String[]
            {"userLeftWork", "userArrivedHome", "userStartedWalking"});

    AuthenticationRequest request = new AuthenticationRequest();
    request.setPermissions(mPermissions);

    mNeuraApiClient.authenticate(NEURA_AUTHENTICATION_REQUEST_CODE, request);
}



@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == NEURA_AUTHENTICATION_REQUEST_CODE && resultCode == FragmentActivity.RESULT_OK) {
        }
    }

}


Solution

  • Your code seems fine to me, as long as

    1. app_uid is set to your own project.
    2. app_secret is set to your own project.

    I think that if app_uid and app_secret are right, than you need to check if the package you've declared in your application :

    package_name_neura_dev_site

    matches your main package in the code (in gradle & manifest)

    enter image description here