当我尝试用google+向googleplus发布图片时,我一直得到一个plusshare.builder未安装的错误。为什么只有当我试着发布一个图片时才能找到这个活动?张贴文本和内容URL将很好地工作,并拉动google+发布。
我的活动:
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
发布于 2015-05-19 03:38:15
您应该尝试.setstream而不是.addstream,也可以尝试只输入图像/*类型
https://stackoverflow.com/questions/30162512
复制相似问题