如您所见,Google在Android设置中提供了一种选择系统范围的色彩强调的方法:
我首先认为这不可能在我的应用程序中使用,但是Gboard成功地将其用于主题UI元素,正如我们在此新闻中看到的那样:https ://9to5google.com/2019/05/08/android-q -gboard-accent-color /
然后,我想知道这是一个公共API,还是有一种方法可以从一种或另一种方法获取它。
感谢您的任何想法。
尽管 Internet 上的许多教程、视频和书籍都显示baseline edit. delete constraint和cycle chain mode 按钮(x,ab和chain按钮)位于布局编辑器中所选组件下方,我在更新的Android Studio 3.4中看不到它们。这怎么可能?我只能使用上下文菜单执行这些操作。
假设有一个网站https://www.example.com 并且我们正在 使用以下意图过滤器在 Android 应用程序中收听https://www.example.com/product
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.com"
android:pathPrefix="/product"
android:scheme="https" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
并且文件 assetlinks.json 也托管在 example.com 上
Android 应用程序链接按预期工作正常。
现在,如果用户转到浏览器并打开 example.com 并且用户单击将在应用程序中打开的https://example.com/product但我们希望仅当用户在我们的网站上时阻止应用程序打开
任何帮助将不胜感激。
我想测试ViewHolder我每个人中包含的文本RecyclerView:
@RunWith(AndroidJUnit4.class)
public class EspressoTest {
private Activity mMainActivity;
private RecyclerView mRecyclerView;
private int res_ID = R.id.recycler_view_ingredients;
private int itemCount = 0;
//TODO: What is the purpose of this rule as it relates to the Test below?
@Rule
public ActivityTestRule<MainActivity> firstRule = new ActivityTestRule<>(MainActivity.class);
//TODO: Very confused about Espresso testing and the dependencies required; it appears Recyclerview
//TODO: Requires additional dependencies other than those mentioned in the Android documentation?
//TODO: What would be best method of …Run Code Online (Sandbox Code Playgroud) 如何将文件上传到 google drive -Google drive API 中的特定文件夹?我有这个代码,它将我的文件上传到谷歌驱动器中的主文件夹。
$client->setAccessToken($_SESSION['accessToken']);
$service = new Google_DriveService($client);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$file = new Google_DriveFile();
foreach ($files as $file_name) {
$file_path = 'files/'.$file_name;
$mime_type = finfo_file($finfo, $file_path);
$file->setTitle($file_name);
$file->setDescription('This is a '.$mime_type.' document');
$file->setMimeType($mime_type);
$service->files->insert($file, array(
'data' => file_get_contents($file_path),
'mimeType' => $mime_type
));
}
Run Code Online (Sandbox Code Playgroud) 我尝试编写一个小测试来尝试 Espresso。
package com.mycompany.myapp.somemodule
import com.mycompany.myapp.R
import other.uselful.imports
@RunWith(AndroidJUnit4::class)
@LargeTest
class DemoTest {
@get:Rule
var startActivity: ActivityTestRule<StartActivity> = ActivityTestRule(StartActivity::class.java)
@Test
fun aDemoTest() {
onView(withId(R.id.theElementId))
.check(matches(isClickable()))
}
}
Run Code Online (Sandbox Code Playgroud)
Android Studio 没有显示任何错误。如果我 ctrl+click R.id.theElementID,它会在适当的布局文件中找到它。但是,当我尝试运行时,出现编译错误:
未解析的参考:id
我该如何解决这个问题?
androidTest目录下写了一些测试用例。testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner")添加的依赖项:
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
还添加了 JaCoCo 作为依赖项。
createDebugAndroidTestCoverageReportGradle 任务时,所有测试用例都成功运行,但报告中的覆盖率为 0%我猜这是由于这个错误:
V/InstrumentationResultParser:错误:无法生成 Emma/JaCoCo 覆盖范围。V/InstrumentationResultParser:INSTRUMENTATION_CODE:-1
Android 3.5.1
Run Code Online (Sandbox Code Playgroud)
我使用的是WebView,我注意到当我重写某些方法时,所有参数都是可为null的类型:
webview.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
return super.shouldOverrideUrlLoading(view, request)
}
}
Run Code Online (Sandbox Code Playgroud)
这意味着我必须使用safe call运算符来使用它们。但是,当我查看WebViewClient从其重写方法的类时,未nullable在Java代码中指定为注释。
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return shouldOverrideUrlLoading(view, request.getUrl().toString());
}
Run Code Online (Sandbox Code Playgroud)
因此,我想到了要从重写方法中删除可空性还是保留它们?
我以前从未制作过 Android 应用程序,这不是一个好的开始。我在 Android 工作室做了一个空白项目作为测试,并尝试在我的华为 P33 手机上运行该程序。当我尝试构建和安装程序时,我收到以下消息;
无法使用命令 cmd package install-commit 389180709 提交安装会话 389180709。错误:INSTALL_FAILED_MISSING_SHARED_LIBRARY:无法在 /data/app/com.example.myapplication-segdjrVZj4KvtCNaJ5W5oQ 中安装包。图书馆 com.google.android.things; 失败!
会话“应用程序”:安装未成功。无法安装应用程序:INSTALL_FAILED_MISSING_SHARED_LIBRARY 重试
我花了大约一个半小时的谷歌搜索,但似乎没有人对 Android Things 库有同样的问题。
在“AndroidManifest.xml”中,如果我更改<uses-library android:name="com.google.android.things" />为<uses-library android:name="com.google.android" />,应用程序会安装但不执行任何操作并在打开后立即崩溃。
我刚刚设置了一个 Bitbucket 管道来在 Docker 容器中构建 Android 应用程序......
但构建后,无法挂载某些未知目录:
> Task :mobile:lintDebug
Wrote HTML report to file:///opt/atlassian/pipelines/agent/build/mobile/build/reports/lint-results-debug.html
BUILD SUCCESSFUL in 2m 51s
41 actionable tasks: 41 executed
Unable to list file systems to check whether they can be watched.
The whole state of the virtual file system has been discarded.
Reason: Could not query file systems: could not open mount file (errno 2: No such file or directory)
Run Code Online (Sandbox Code Playgroud)
这是什么原因/如何消除该错误消息?