所以,当我使用Koush的Ion时,我能够通过一个简单的方式在我的帖子中添加一个json体 .setJsonObjectBody(json).asJsonObject()
我正在转向OkHttp,我真的没有看到一个很好的方法来做到这一点.我到处都收到错误400.
有人有主意吗?
我甚至尝试将其手动格式化为json字符串.
String reason = menuItem.getTitle().toString();
JsonObject json = new JsonObject();
json.addProperty("Reason", reason);
String url = mBaseUrl + "/" + id + "/report";
Request request = new Request.Builder()
.header("X-Client-Type", "Android")
.url(url)
.post(RequestBody
.create(MediaType
.parse("application/json"),
"{\"Reason\": \"" + reason + "\"}"
))
.build();
client.newCall(request).enqueue(new com.squareup.okhttp.Callback() {
@Override
public void onFailure(Request request, IOException throwable) {
throwable.printStackTrace();
}
@Override
public void onResponse(Response response) throws IOException {
if (!response.isSuccessful()) throw new IOException(
"Unexpected code " + response);
runOnUiThread(new Runnable() {
@Override …
Run Code Online (Sandbox Code Playgroud) 我目前正在制作一个导航抽屉,我希望用户照片可以缩放,裁剪,着色,然后用作那张照片的圆形裁剪背后的标题图像.
我甚至无法发布图片,因为这个帐户的代表太低了...该死我,并且在我的大部分问题中使用我的旧学生帐户...
尽管我ImageView
的定义是这样的
<ImageView
android:tint="@color/clyp_copy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/pixplogo"
android:scaleType="centerCrop"
android:adjustViewBounds="true"/>
Run Code Online (Sandbox Code Playgroud)
这对我来说实际上是个常见问题.我从来没有centerCrop
正常工作.我不明白为什么.
测试5.1.1,基于SDK构建.相同的问题21
我正在处理一些Android代码,并且无法构建MediaStyle通知。我已经在大部分媒体播放器和媒体会话中使用了AppCompat,而我还没有使用的内容我打算进行切换,以便保持4.x兼容性。
问题?好吧,我正在尝试发出MediaStyle通知,并为其提供MediaSession令牌。我的support.v4.media.session.MediaSession.Token似乎与media.session.MediaSession.Token不兼容
我已经尝试过投放,而只保留原始状态。老实说,我很困惑,因为文档说它们是兼容的。
如果您需要其余的代码,可以在这里找到代码
或者,您可以在此处查看相关代码。
Intent nIntent = new Intent(context, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, nIntent, 0);
n.setLatestEventInfo(context, notifTitle, notifMessage, pIntent);
notificationManager.notify(notifId, n);
ComponentName c = new ComponentName("com.thefan.android", "BackgroundService");
ms = new MediaSessionCompat(this, "TheFan", c, pIntent);
ms.setMetadata(new MediaMetadataCompat.Builder()
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, artwork)
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, "Pink Floyd")
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, "Dark Side of the Moon")
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, "The Great Gig in the Sky")
.build());
// Indicate you're ready to receive media commands
ms.setActive(true);
// Attach a new Callback to receive MediaSession updates
ms.setCallback(new MediaSessionCompat.Callback() { …
Run Code Online (Sandbox Code Playgroud) android incompatibletypeerror android-appcompat android-notifications android-mediaplayer