我正在尝试从Google Map共享位置链接获取位置,因此我正在使用Google Shorten URL API来扩展URL,但是当我从android设备从Google Map应用程序共享URL时,它会提供https://maps.app.goo.gl/eEhh3这种URL。它没有给我实际的扩展URL以提供位置信息。
如何扩展这个:
https://maps.app.goo.gl/eEhh3
在此链接中:
https://www.google.com/maps/place/Siddique+Trade+Center/@31.5313297,74.3504459,17z/data=!3m1!4b1!4m5!3m4!1s0x391904e4af9b1e35:0xee6f3c848c9e5341!8m2!3d31.5313297!4d74.3526346
Run Code Online (Sandbox Code Playgroud)
这是我用来扩展它的API URL。
“ https://www.googleapis.com/urlshortener/v1/url?shortUrl=https://maps.app.goo.gl/eEhh3&key=(API_KEY)”
但是,没有给我上面的位置信息URL,而是给我返回了这个Long URL。
https://maps.app.goo.gl/?link=https://www.google.com/maps/place//data%3D!4m2!3m1!1s0x391904e4af9b1e35:0xee6f3c848c9e5341?utm_source%3Dmstt_1&apn=com.google.android.apps.maps&ibi=com.google.Maps&ius=comgooglemapsurl&isi=585027354
Run Code Online (Sandbox Code Playgroud)
请帮助我如何通过Google API获取上述位置信息URL,以便从任何设备(IOS,WebAPP,特别是Android)通过Google Map共享位置网址获取位置(纬度,经度)。
我正在开发一个android项目,并且用两种语言本地化了我的应用程序,问题是,当我直接从android studio运行我的应用程序但在Google Play商店中上传项目并从Play商店下载该应用程序时,它运行良好它的本地化在某些版本的Android中不起作用。
这是设置本地语言的Java代码。
private static Context updateResources(Context context) {
Locale locale = new Locale("fa","AF");
Locale.setDefault(locale);
Resources res = context.getResources();
Configuration config = new Configuration(res.getConfiguration());
if (Build.VERSION.SDK_INT >= 17) {
config.setLocale(locale);
context = context.createConfigurationContext(config);
} else {
config.locale = locale;
res.updateConfiguration(config, res.getDisplayMetrics());
}
return context;
}
Run Code Online (Sandbox Code Playgroud)
这是我的英文版面文件。
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="update">Update</string>
<string name="app_version_title">New version</string>
<string name="app_version_title_second">is now available</string>
<string name="logout_msg">Are you sure you want to logout?</string>
<string name="logout_title">Log Out?</string>
<string name="languages">Languages</string>
<string name="km">Km</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
这是我的Persion布局文件。
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string …Run Code Online (Sandbox Code Playgroud) 尝试使用滑动时我遇到了错误,但似乎已经折旧了.建议是使用,TouchAction()但我不知道如何将滑动转换为TouchAction().
以下是代码:
public void obj_scrollToObjectByCoOrds(int coOrds) throws IOException {
try {
List<WebElement> elements = driver.findElements(By.className("android.widget.FrameLayout"));
Point point = elements.get(1).getLocation();
Dimension size = elements.get(1).getSize();
int elementCenterX = point.getX() + Math.round(size.getWidth() / 2);
int elementCenterY = point.getY() + Math.round(size.getHeight() / 2);
String originalContext = driver.getContext();
driver.context("NATIVE_APP");
driver.swipe(elementCenterX, elementCenterY, elementCenterX, elementCenterY + coOrds, 1500);
driver.context(originalContext);
} catch (Exception e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
下面是一个我努力实现的示例touchAction,所以我暂时将其作为示例.我想看看转换是如何发生的,所以我通过比较下面的代码和答案来解释:
Dimension screenSize = driver.manage().window().getSize();
new TouchAction(driver)
.press((int) (screenSize.width * 0.6), 130)
.waitAction(500)
.press((int) (screenSize.width * …Run Code Online (Sandbox Code Playgroud) 我有recyclerview,为此,我使用了一个特定的视图。在那个视图中,我有 3textviews和一个图像按钮。先给textview我看数字。其他一些虚拟文本。当我的数字超过 10(2 个字符)时,除数字外的所有内容都向右移动。我该如何处理?
这是我的xml文件:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="70dp">
<LinearLayout
android:id="@+id/linlay"
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:gravity="center_vertical">
<TextView
android:id="@+id/buses_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textSize="25dp"
android:textColor="@color/gradStop"
android:layout_marginLeft="15dp"/>
<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/buses_route_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
android:text="Bus Route"
android:textColor="@color/gradStart"
android:textSize="20dp"/>
<TextView
android:id="@+id/buses_cycle_duration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
android:text="Duration"
android:textColor="@color/gradStop"
android:textSize="20dp"/>
</LinearLayout>
<ImageButton
android:id="@+id/buses_favourites"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_favorite_border_black_24dp"
android:background="@color/transparent"
android:layout_alignParentRight="true"/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是屏幕截图:
我正在开发一个需要每小时执行一次后台任务的Android应用(作业调度程序或服务)。当应用程序运行时,任务会执行,但是一旦我从前台杀死该应用程序,服务就无法工作。还有另一种方法可以做到这一点吗?
1.服务
public class NotificationService extends JobService {
private void PrintLog()
{
Log.d("DGVCL", "PrintLog()");
}
@Override
public boolean onStartJob(JobParameters jobParameters) {
Log.d("DGVCL", "onStartJob()");
PrintLog();
jobFinished(jobParameters, false);
return true;
}
@Override
public boolean onStopJob(JobParameters jobParameters) {
Log.d("DGVCL", "onStopJob()");
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
2.主要活动
JobScheduler jobScheduler = (JobScheduler)getApplicationContext().getSystemService(JOB_SCHEDULER_SERVICE);
ComponentName componentName = new ComponentName(this, NotificationService.class);
JobInfo jobInfo = new JobInfo.Builder(1, componentName)
.setPeriodic(Global.NOTIFICATION_TIME_PERIOD)
.setBackoffCriteria(Global.NOTIFICATION_TIME_PERIOD, JobInfo.BACKOFF_POLICY_LINEAR)
.setPersisted(true).build();
jobScheduler.schedule(jobInfo);
Run Code Online (Sandbox Code Playgroud)
3.清单
<service android:name="com.hopesndreams.hiren.hd.service.NotificationService" android:permission="android.permission.BIND_JOB_SERVICE" >
</service>
Run Code Online (Sandbox Code Playgroud) 我不久前就遇到了这个异常,我无法从堆栈跟踪中找到任何有用的信息,Crashlytics 报告它发生在 Android 8 和 9 上
这是堆栈跟踪:
Fatal Exception: java.lang.IndexOutOfBoundsException: measureLimit (54) is out of start (55) and limit (54) bounds
at android.text.TextLine.handleRun(TextLine.java:989)
at android.text.TextLine.measureRun(TextLine.java:500)
at android.text.TextLine.measure(TextLine.java:337)
at android.text.TextLine.metrics(TextLine.java:272)
at android.text.Layout.getLineExtent(Layout.java:1370)
at android.text.Layout.drawText(Layout.java:519)
at android.text.Layout.draw(Layout.java:292)
at android.widget.TextView.onDraw(TextView.java:7765)
at android.view.View.draw(View.java:20370)
at android.view.View.updateDisplayListIfDirty(View.java:19315)
at android.view.View.draw(View.java:20093)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19306)
at android.view.View.draw(View.java:20093)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.draw(View.java:20373)
at android.support.v4.widget.NestedScrollView.draw(NestedScrollView.java:1888)
at android.view.View.updateDisplayListIfDirty(View.java:19315)
at android.view.View.draw(View.java:20093)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1246)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19306)
at android.view.View.draw(View.java:20093)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19306) …Run Code Online (Sandbox Code Playgroud) 我有一个卡片视图,动态列出一组卡片。我为此使用了recyclerview。现在我想通过使卡变灰或类似的方式来禁用卡(基于值)。这是包含卡片视图的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="112dp"
android:layout_height="140dp"
android:layout_margin="10dp"
android:clickable="true"
android:focusable="true"
android:scaleType="fitXY">
<RelativeLayout
android:layout_width="100dp"
android:layout_height="150dp"
android:padding="8dp">
<ImageView
android:id="@+id/appIcon"
android:layout_width="match_parent"
android:layout_height="62dp"
android:padding="5dp"
tools:ignore="VectorDrawableCompat" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/appIcon"
android:layout_centerInParent="true"
android:gravity="center"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="@drawable/selector"
android:textSize="10dp"
android:textStyle="bold" />
<TextView
android:id="@+id/appVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="5dp"
android:layout_marginEnd="1dp"
android:text="version 0.0"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textSize="8dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我找到了一些相关的查询,并尝试使用选择器并将每个字段而不是整个卡片变灰。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:color="@color/colorAppName" />
<item android:state_enabled="false" android:color="@color/colorPrimary" />
</selector>
Run Code Online (Sandbox Code Playgroud)
在我的班级(Adapter.kt)
name = itemView.findViewById(R.id.name) as TextView
if(value==true)
{
name.isEnabled=false
}
Run Code Online (Sandbox Code Playgroud)
但我想禁用整个卡。请帮忙
我正在使用颤振开发图书应用程序。我正在使用每一章的页面浏览显示书页。问题是当用户在最后一页上向左滑动时,我应该从数据库中加载下一章以及章节标题。反之亦然,在上一章的第一页上向右滑动。那么如何在第一页或最后一页找到该用户并向左或向右滑动?
我有以下代码片段:
public static String getAppVersion(Context context) {
String versionName = null;
try {
versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; //This is the problematic line
} catch (NameNotFoundException e) {
e.printStackTrace();
}
return versionName;
}
Run Code Online (Sandbox Code Playgroud)
现在,根据 Crashlytics 的说法,应用程序崩溃时出现了以下异常:
Caused by android.os.DeadObjectException
com.tawkon.data.lib.util.ParameterUtils.getAppVersion
android.os.BinderProxy.transactNative (Binder.java)
android.os.BinderProxy.transact (Binder.java:503)
android.content.pm.IPackageManager$Stub$Proxy.getPackageInfo (IPackageManager.java:2684)
android.app.ApplicationPackageManager.getPackageInfo (ApplicationPackageManager.java:193)
com.tawkon.data.lib.util.ParameterUtils.getAppVersion (ParameterUtils.java:44)
com.tawkon.data.lib.helper.analytics.NetworkRequestHelper.generateHttpRequest (NetworkRequestHelper.java:28)
com.tawkon.data.lib.service.DataThroughputScanJobIntentService$2.onTestFinished (DataThroughputScanJobIntentService.java:342)
com.tawkon.data.lib.collector.DataThroughputManager$1.run (DataThroughputManager.java:171)
Run Code Online (Sandbox Code Playgroud)
设备规格为三星,操作系统为 6。
就我而言,这似乎是一次罕见的崩溃。无论如何,什么可能导致这种情况发生?我怎样才能防止它再次发生?
我昨天更新了 Gradle 插件,现在 android studio 无法构建我的应用程序。该应用程序显示以下错误。
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve io.grpc:grpc-core:[1.16.1].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve io.grpc:grpc-core:[1.16.1].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve io.grpc:grpc-core:[1.16.1].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve io.grpc:grpc-core:[1.16.1].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve …Run Code Online (Sandbox Code Playgroud) android ×8
appium ×1
dart ×1
flutter ×1
geolocation ×1
google-maps ×1
java ×1
kotlin ×1
maps ×1