Tag: android 8.0 oreo

Android O – 后台服务限制无法按预期工作

我只是根据Android O背景限制测试我现有的Android应用程序。 在测试中,我发现了一种奇怪的行为。 所以基本上在我的应用程序中,我正在使用后台服务,我在第一个活动中启动它。 所以现在问题是一旦活动和后台服务开始,我正在使用后退按钮关闭我的活动。 因此,根据服务概念,它会在后台运行。 大约1分钟后, onDestroy()方法被调用后台服务,但服务仍然在运行。 理想情况下,根据文档,它应该被杀死。 所以,我不知道这是一个问题还是什么问题。 作为参考,我创建了一个反映相同场景的示例代码,如下所示: 脚步 开始申请 单击“开始后台服务”按钮。 使用后退按钮关闭应用程序。 HomeActivity.java package com.icpl.otest; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import com.icpl.otest.service.MyService; public class HomeActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } public void onStartServiceClick(View view) […]

android oreo上的永久服务

Android 8的电池消耗改进对用户来说很好,但是如果我的服务能按预期工作,我有点害怕。 首先:感谢您提出任何建议,但我不能只安排我的服务。 我希望一直在后台运行一个类似OK Google的关键词监听器。 它将基于开源的pocketsphinx-android库。 我知道这会消耗很多电池电量,我会告诉用户这个。 我们可以在android 8+上创建永久后台服务吗? 我需要在gradle中定位android 8,因为我期待一些旧目标的bug。 我也不想使用前台服务来惹恼用户,该服务会在状态栏中永久显示通知。 [ https://developer.android.com/about/versions/oreo/background.html] – 是否真的无法为我的用例(但最好是所有用例)提供永久性后台服务?

Android 8.0 Oreo – 帐户

在我的应用中,我需要知道是否有任何Google帐户或任何三星帐户。 直到Android 7,很容易获得这样的信息: Account[] accounts = AccountManager.get(getContext()) .getAccountsByType(“com.google”) 但随着Oreo事件的发生,这种情况不再适用。 编辑:查看有关此主题的官方信息: 在Android 8.0(API级别26)中,除非身份validation者拥有帐户或用户授予该访问权限,否则应用程序将无法再访问用户帐户。 GET_ACCOUNTS权限已不再足够。 要授予对帐户的访问权限,应用应使用AccountManager.newChooseAccountIntent()或特定于身份validation器的方法。 访问帐户后,应用程序可以调用AccountManager.getAccounts()来访问它们。 Android 8.0弃用了LOGIN_ACCOUNTS_CHANGED_ACTION。 应该使用addOnAccountsUpdatedListener()代替应用程序在运行时获取有关帐户的更新。 有关为帐户访问和可发现性添加的新API和方法的信息,请参阅本文档新API部分中的帐户访问和可发现性 我花了半天时间找到解决方案,但没有成功。 我发现信息声称现在访问帐户的唯一方法是使用AccountPicker如下所示: AccountPicker.newChooseAccountIntent(null, null, new String[]{“com.google”},true, null, null, null, null); 但这确实回应了我的问题。 为了清楚起见,我只需要知道某个类型的帐户是否存在(Google,三星……)我不需要知道多少,如果是这样,也不需要帐户信息。

如何在没有root的情况下(如Automate和Tasker)可靠地模拟Android上的触摸事件?

如何在我作为后台服务运行的应用程序之外可靠地模拟Android上的触摸事件(无需root)? 虽然之前已经提出过这个问题,但大多数答案都使用了ADB 。 (例如如何模拟Android设备上的触摸事件? ) https://github.com/chetbox/android-mouse-cursor使用辅助function提供了一个很好的解决方案,但不是很可靠,因为并非所有视图都对它做出响应,并且游戏在大多数时间都没有响应。 private void click() { AccessibilityNodeInfo nodeInfo = getRootInActiveWindow(); if (nodeInfo == null) return; AccessibilityNodeInfo nearestNodeToMouse = findSmallestNodeAtPoint(nodeInfo, cursorLayout.x, cursorLayout.y + 50); if (nearestNodeToMouse != null) { logNodeHierachy(nearestNodeToMouse, 0); nearestNodeToMouse.performAction(AccessibilityNodeInfo.ACTION_CLICK); } nodeInfo.recycle(); } 这是https://github.com/chetbox/android-mouse-cursor使用的当前代码。 Android版本是8.0,现货Android 是否有更好,更可靠的方法来模拟Java中的这些触摸事件? 提前致谢!

android oreo的后台服务

如何在没有显示通知点的情况下在android Oreo中继续后台服务? 我使用通知继续我的后台服务,但我不想显示运行服务的通知。

Intent.ACTION_SEND无法在Oreo上工作

我正在开发一个自定义相机应用程序,它捕获图片并将其存储在图库中。 当我使用Intent.ACTION_SEND共享该图像时,除了具有API 26的设备(即OREO)之外,它在所有设备上都能正常工作。 我分享图片的代码是: Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType(“image/jpeg”); Uri uriShare = Uri.fromFile(outFile); //outfile is the path of the image stored in the gallery shareIntent.putExtra(Intent.EXTRA_STREAM, uriShare); startActivity(Intent.createChooser(shareIntent, “”)); 任何人都可以帮我解决这个问题吗?