启动Google云端硬盘文件选择器意图时,应用停止工作

时间:2014-08-30 19:25:27

标签: android google-drive-android-api

我尝试在同一个活动中实施导出和导入(分别来往Google云端硬盘)到我的应用的可用性。

导出功能完美无缺。对于导入功能,我曾考虑使用播放服务中的Google Drive File Picker来获取要导入的txt文件的ID,然后读取该文件并将其导入我的数据库。

好吧,首先我连接到谷歌Api客户端,它确实可以用于导出。 在onConnected方法中,我使用一个开关来导入或导出之间的分隔:

public void onConnected(Bundle connectionHint) {
    switch(driveCase){
        case 0:
            Log.i(TAG, "API client connected for export.");
            saveFileToDrive();
            break;
        case 1:
            Log.i(TAG, "API client connected for import.");
            pickFileFromDrive();
            readFileFromDrive();
            break;
    }
}

首先,我想显示GDrive文件选择器,所以:

private void pickFileFromDrive(){
    Log.i(TAG, "Open FilePicker Activity.");
    IntentSender intentPicker = Drive.DriveApi
            .newOpenFileActivityBuilder()
            .setMimeType(new String[] { "text/plain" })
            .build(mGoogleApiClient);



    try {
        startIntentSenderForResult(
                intentPicker, REQUEST_CODE_OPENER, null, 0, 0, 0);
    } catch (SendIntentException e) {
      Log.w(TAG, "Unable to send intent", e);
    }


}

这就是应用程序崩溃的点,文件选择器显示但我的应用程序停止工作......

这是onActivityResult:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i(TAG, "Taking result...");

            DriveId driveId = (DriveId) data.getParcelableExtra(
                    OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);
            pickedDriveId = driveId;

            Log.i(TAG, "Result Toke.");
        finish();

    }

关于可能是什么原因的任何想法?

提前致谢。

编辑: 这是logcat跟踪

    08-30 22:25:33.110: E/SyncSchedulerImpl(25559): Ignoring sync request:  rate limited (on connection limit)
08-30 22:25:33.180: I/android-drive-quickstart(26434): API client connected for import.
08-30 22:25:33.180: I/android-drive-quickstart(26434): Open FilePicker Activity.
08-30 22:25:33.188: I/ActivityManager(401): START u0 {act=android.intent.action.PICK cmp=com.google.android.gms/.drive.data.ui.open.OpenFileActivityDelegate (has extras)} from pid -1
08-30 22:25:33.727: W/ActivityManager(401): Activity pause timeout for ActivityRecord{41e01cc8 u0 com.example.estudiame/.MyTestsActivity}
08-30 22:25:34.008: D/dalvikvm(401): GC_EXPLICIT freed 5376K, 38% free 32505K/52376K, paused 4ms+22ms, total 193ms
08-30 22:25:34.133: I/ActivityManager(401): Displayed com.google.android.gms/.drive.data.ui.open.OpenFileActivityDelegate: +400ms
08-30 22:25:34.157: E/SyncSchedulerImpl(25559): Ignoring sync request:  rate limited (on connection limit)
08-30 22:25:34.196: I/BaseActivity(25559): GoogleApiClient connected
08-30 22:25:34.212: D/dalvikvm(25559): GC_CONCURRENT freed 361K, 4% free 11087K/11480K, paused 3ms+8ms, total 57ms
08-30 22:25:44.462: W/ActivityManager(401): Activity stop timeout for ActivityRecord{41e01cc8 u0 com.example.estudiame/.MyTestsActivity}

0 个答案:

没有答案