1

I am trying to integrate my NDK application with Google Drive. I am following the Sample Application and adapting it to being used from my native code. I have gotten it to launch the account picker successfully, but am now stuck at how to get the result from the account picker. I launch the account picker using JNI calls from my code

In the code sample, the onActivityResult method is called on the activity when other intents return.

@Override
  protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    switch (requestCode) {
    case REQUEST_ACCOUNT_PICKER:
      if (resultCode == RESULT_OK && data != null && data.getExtras() != null) {
        String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
        if (accountName != null) {
          credential.setSelectedAccountName(accountName);
          service = getDriveService(credential);
          startCameraIntent();
        }
      }
      break;
    }
  }

Is there a way to do a similar thing using the NDK? I want to create a function in C and set it as the callback for onActivityResult.

4

1 回答 1

0

唯一的解决方案是一个不太理想的解决方案。您必须创建 NativeActivity 的 Java 子类,并在那里实现 onActivityResult 结果。在您的 AndroidManifest.xml 中,您将引用新的子类activity android:name=""而不是 NativeActivity。

于 2016-07-27T21:00:24.500 回答