google-加上图片上传 post 抛出带有图片 Uri 的 ActivityNotFoundException

google-plus image upload post throwing ActivityNotFoundException with image Uri

当我尝试 post 图像到 googleplus 和 plusshare.builder 时,我不断收到 google+ 未安装错误。 为什么仅当我尝试 post 图像时才找不到 activity? 发布文本和内容 URL 将正常工作,并将 google+ 拉到 post.

我的activity:

         String gPlusSmallUrl = intent.getStringExtra("gPlusCropUrl");
         String statusString = intent.getStringExtra("statusString");
            ContentResolver cr = this.getContentResolver();
            String mime = cr.getType(googleUri);

            Intent shareIntent = new PlusShare.Builder(this)
                    //.setType("text/plain") //posting with this works
                    .setText("example text here")// posting with this works
                    .addStream(googleUri)   //when i try to add an image it gives me a google+ not installed error
                    .setType(mime)// this is part of the failure too!
                    //.setContentUrl(Uri.parse(gPlusSmallUrl))//Posting with this also works fine.
                    .getIntent();
try {
                startActivityForResult(shareIntent, 0);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(this, "You haven't installed google+ on your device", Toast.LENGTH_SHORT).show();
            }
            Log.i(TAG, "Posted to GooglePlus");

        }
        GooglePlusActivity.this.setResult(GOOGLE_LOGIN_RESULT_CODE_SUCCESS);
        finish();
    }

清单: 权限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_PROFILE" />

<meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

<activity
            android:name=".GooglePlusActivity"
            android:label="@string/title_activity_google_plus" >
        </activity>
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

我不明白为什么添加图片 Uri 会抛出 ActivityNotFoundException

您应该尝试使用 .setstream 而不是 .addstream 也可以试试 image/* type