当我尝试使用plusshare.builder将图像发布到googleplus时,我一直收到谷歌+未安装的错误。 为什么仅在我尝试发布图像时才找到活动? 发布文字和内容网址的工作正常,并将谷歌+发布到帖子中。
我的活动:
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
答案 0 :(得分:-1)
你应该尝试.setstream而不是.addstream 也可以试试image / * type