我在http://developers.google.com/+/mobile/android/share/deep-link上尝试使用Google+中的深层链接到Android应用.
我可以分享到Google+.帖子中的链接是"可点击的"(在触摸期间突出显示),但在发布时不做任何操作.此外,帖子包含可疑的"未定义"文本行.
样本http://raw.github.com/concreterose/TestDeepLink/master/README_ASSETS/sample_share.png
我在Google Developers Console项目凭据中启用了深层链接.
我正在使用使用Scopes.PLUS_LOGIN创建的已登录PlusClient,通过以下方式发布:
Intent shareIntent = new PlusShare.Builder(this, plusClient)
.setText("Testing deep link")
.setType("text/plain")
.setContentDeepLinkId("deeplink",
"title",
"description",
Uri.parse(thumbnailUrl))
.getIntent();
startActivityForResult(shareIntent, 0);
Run Code Online (Sandbox Code Playgroud)
我不确定我是否需要所有这些,同时试图让我的工作变得有效:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
Run Code Online (Sandbox Code Playgroud)
处理活动(作为清单中的第一个活动):
<activity android:name=".ParseDeepLinkActivity">
<intent-filter>
<action android:name="com.google.android.apps.plus.VIEW_DEEP_LINK" />
<data android:scheme="vnd.google.deeplink" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
是:
public class ParseDeepLinkActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "onCreate");
throw new RuntimeException("got here");
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用发布密钥库构建并在运行4.4的几个真实设备上进行测试. …
有没有办法用来Intent.ACTION_SEND共享屏幕截图而不需要android.permission.WRITE_EXTERNAL_STORAGE?
这是分享部分:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jpeg");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
Intent chooserIntent = Intent.createChooser(shareIntent, shareTitle);
startActivity(chooserIntent);
Run Code Online (Sandbox Code Playgroud)
当uri指向文件时getExternalFilesDir(),共享工作正常,但我更喜欢不需要WRITE_EXTERNAL_STORAGE隐私相关用户许可的解决方案.
我尝试了3种不同的方法:
文件提供者:
uri = FileProvider.getUriForFile(context, authority, imageFile);
Run Code Online (Sandbox Code Playgroud)这适用于某些共享样式(Gmail)但不适用于其他共享样式(Google+).
上传到Web服务器:
uri = Uri.parse("http://my-image-host.com/screenshot.jpg");
Run Code Online (Sandbox Code Playgroud)这在所有地方都失败了,一些人(Google+)崩溃了.
(我怀疑如果我使用每个社交网络API而不是自己实现共享逻辑,这可能会有效chooserIntent)
注入Media Store:
uri = MediaStore.Images.Media.insertImage(contentResolver, bitmap, name, description);
Run Code Online (Sandbox Code Playgroud)这会引发SecurityException,解释它需要WRITE_EXTERNAL_STORAGE.
我还缺少其他方法吗?