我需要将日期格式化为特定的字符串.
我使用SimpleDateFormat类来格式化日期,使用模式" yyyy-MM-dd'T'HH:mm:ssZ"它将当前日期返回为
" 2013-01-04T15:51:45+0530",但我需要为
" 2013-01-04T15:51:45+05:30".
以下是使用的编码,
Calendar c = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.ENGLISH);
Log.e(C.TAG, "formatted string: "+sdf.format(c.getTime()));
Run Code Online (Sandbox Code Playgroud)
输出:格式化字符串:2013-01-04T15:51:45+0530
我需要格式2013-01-04T15:51:45+05:30只是在gmt时间之间添加冒号.
因为我正在使用Google日历来插入活动,所以它只接受我提到的所需格式.
我需要从纬度和经度获得城市和州.Geocoder执行此功能以获得城市和州.但我java.io.IOException: grpc failed只在Android真实设备上收到错误.它在模拟器中运行良好.
new Geocoder(context).getFromLocation(latLng.latitude, latLng.longitude, 1).get(0);
Run Code Online (Sandbox Code Playgroud)
此外,我一直在使用Asynctask调用此函数,这是在另一篇文章中建议的Geocoder grpc在堆栈溢出失败,但对我没有任何作用.
我也重启了设备但仍然失败了.
需要帮助.提前致谢.
注意:我测试了Google Pixel XL,三星S6边缘,三星S4.
android google-maps latitude-longitude android-location google-geocoder
你如何让textview被证明是合理的?有可能得到解决方案吗?我搜索过大多数论坛,但我没有弥补.请帮帮我.
我无法获取公开个人资料网址并从Android中的LinkedIn api获取或发布.我正在使用linkedin-j-android源码.我能够获得成功的accessstoken但是从这个线路调用时OnNewIntent.
编辑:我在我的应用程序中拥有互联网权限.所以这不会是个问题.
Person profile = client.getProfileForCurrentUser(EnumSet.of(ProfileField.PUBLIC_PROFILE_URL));
Run Code Online (Sandbox Code Playgroud)
@Override
protected void onNewIntent(Intent intent) {
String verifier = intent.getData().getQueryParameter("oauth_verifier");
LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(liToken, verifier);
client = factory.createLinkedInApiClient(accessToken);
Person profile = client.getProfileForCurrentUser(EnumSet.of(ProfileField.PUBLIC_PROFILE_URL));
Log.v("","PUBLIC_PROFILE_URL:" + profile.getPublicProfileUrl());
}
Run Code Online (Sandbox Code Playgroud)
应用程序崩溃.以下是日志跟踪.
FATAL EXCEPTION: main
com.google.code.linkedinapi.client.LinkedInApiClientException: java.io.IOException: BufferedInputStream is closed
at com.google.code.linkedinapi.client.impl.LinkedInApiXppClient.unmarshallObject(LinkedInApiXppClient.java:167)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.readResponse(BaseLinkedInApiClient.java:3710)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.callApiMethod(BaseLinkedInApiClient.java:3777)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.callApiMethod(BaseLinkedInApiClient.java:3725)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.getProfileForCurrentUser(BaseLinkedInApiClient.java:1122)
Run Code Online (Sandbox Code Playgroud)
请帮我.提前致谢.
我的Android应用程序中的触摸侦听器有问题.OnTouchLIstenr不适用于视图,即ACTION_DOWN在侦听器中表现良好,但ACTION_UP不会调用.我不知道发生了什么问题.但是,如果我设置虚拟点击监听器,两者都工作正常.为什么会这样?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView image = (ImageView) findViewById(R.id.image);
image.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
ImageView img = (ImageView) v;
int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN){
img.setImageResource(R.drawable.port);
}else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL){
img.setImageResource(R.drawable.bar);
}
return false;
}
});
}
Run Code Online (Sandbox Code Playgroud) 我正在使用带有 Google Maps v2 播放服务的Google Map Android 集群实用程序。
我无法查看具有相同位置的标记。集群显示为 10,即使使用最大缩放我也无法查看这 10 个标记。我想知道将偏移量添加到具有相同位置的标记的位置的可能性。集群实用程序中是否有任何预定义的方法可以解决这个问题。
提前致谢。
