在后台发出颤动的声音警报,并在单击通知时取消。
我正在尝试创建一个用于测试/学习颤振的基本警报应用程序。我的应用程序的高级设计如下所示:
创建警报:
(A)。用户创建警报
(b)。我使用 android_alarm_manager 来安排闹钟
(c)。在闹钟回调中,我使用 FlutterRingtonePlayer.playAlarm()
(d)。用于flutter_local_notification在闹钟响起时显示通知,以便用户可以取消闹钟。
当用户点击通知时:
我收到 的回调flutter_local_notification,它打开了应用程序。
我FlutterRingtonePlayer.stop()这样做了,但这并不能阻止警报。
它现在不起作用,因为FlutterRingtonePlayer当应用程序从通知再次启动时会再次构建。
我能想到的可能的解决方案是:
FlutterRingtonePlayer在手机的共享内存中,以便我可以在取消闹钟时重复使用它。也许以某种方式序列化它?还有更多吗?有更好的方法来做到这一点吗?
Here is my code:
--------------- Scheduling alarm -----------------------------------
void scheduleAlarm(Alarm alarm) {
alarm.alarmTime =
getUpdatedAlarmDateTime(TimeOfDay.fromDateTime(alarm.alarmTime));
AndroidAlarmManager.oneShot(
alarm.alarmTime.difference(DateTime.now()), alarm.alarmId, soundAlarm,
wakeup: true, alarmClock: true, rescheduleOnReboot: true);
}
void soundAlarm(int alarmId) async {
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
'your channel id', 'your channel name', 'your channel description',
importance: Importance.Max, priority: Priority.High, ticker: 'ticker');
var …Run Code Online (Sandbox Code Playgroud) 当我尝试从 AVD 管理器启动模拟器时,显示一条消息:
emulator: Android emulator version 30.5.3.0 (build_id 7196367) (CL:N/A)
dyld: Library not loaded: /System/Library/Frameworks/IOUSBHost.framework/Versions/A/IOUSBHost
Referenced from: /Users/<UserName>/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-i386
Reason: image not found
Run Code Online (Sandbox Code Playgroud)
问题出在哪里?
预先感谢您的任何帮助。
基本上,我想要做的是用一堆初始数据为我的网络应用程序设置我的数据库。例如,有一个产品列表,所有产品都具有一个 product_type。
我seeds.rb有以下代码:
ProductType.delete_all
ProductType.create(:name => 'Furniture')
Product.delete_all
Product.create(:name => 'Chair', :type_id => ProductType.first.id, :packaging => '2 for $20', :price_per => 0.1, :default_packaging_number => 2)
Run Code Online (Sandbox Code Playgroud)
现在,我的问题ProductType.first.id是 只是一个占位符。我真正想做的是放一些类似的东西:
:type_id => ProductType.where(:name => "Furniture").id
Run Code Online (Sandbox Code Playgroud)
问题是,当我这样做时,我得到了一个巨大的数字 (70247318042560),这显然不是 id。控制台也返回警告
warning Object#id will be deprecated; use Object#object_id
Run Code Online (Sandbox Code Playgroud)
当我.object_id在 where 语句的末尾使用时,它仍然返回相同的大且不正确的数字。
如何ProductType从数据库中提取家具的 id ?我需要修改权限或其他东西才能访问它吗?
我有一个包含片段的活动。运行 Leak Canary,我发现该活动存在内存泄漏。
我已经注释掉了活动和片段中的所有代码,其中活动仅显示片段并且片段具有空的 xml 布局。我在文件或 xml 中都没有可访问性。
* AccessibilityManager$1.!(this$0)! (anonymous subclass of android.view.accessibility.IAccessibilityManagerClient$Stub)
* ? AccessibilityManager.!(mTouchExplorationStateChangeListeners)!
* ? CopyOnWriteArrayList.!(elements)!
* ? array Object[].!([2])!
* ? AccessibilityManagerCompat$TouchExplorationStateChangeListenerWrapper.!(mListener)!
* ? BaseTransientBottomBar$SnackbarBaseLayout$1.!(this$0)! (anonymous implementation of android.support.v4.view.accessibility.AccessibilityManagerCompat$TouchExplorationStateChangeListener)
* ? Snackbar$SnackbarLayout.mContext
* ? ContextThemeWrapper.mBase
* ? MessagesActivity
Run Code Online (Sandbox Code Playgroud) 我已经编写了UserService关于用户的类(在逻辑层,而不是持久层),它包含这些方法。
具有这些方法的此类是否违反了SRP?
python
class UserService:
repository: Repository
def create(...):
self.repository.save(...)
def patch(...):
self.repository.patch(...)
def delete(...):
self.repository.delete(...)
def get_one(...):
return self.repository.get(...)[0]
def get_list(...):
return self.repository.save(...)
Run Code Online (Sandbox Code Playgroud)
如果这有很多职责我该如何分配课程?
我的代码:
import numpy as np
from pandas import read_csv
from matplotlib import pyplot as plt
from sklearn.neural_network import MLPClassifier
from sklearn.model_selection import train_test_split
data = read_csv('data.csv', usecols=['col_1'])
df_x = data.iloc[:, 1:]
df_y = data.iloc[:, 0]
x_train, x_test, y_train, y_test = train_test_split(df_x, df_y, test_size=0.9, random_state=4)
nn = MLPClassifier(activation='logistic', solver='sgd', hidden_layer_sizes=(2,), random_state=1)
#nn.fit(x_train[x], y_train[x])
print(nn)
nn.fit(x_train, y_test)
pred = nn.predict(x_test)
Run Code Online (Sandbox Code Playgroud)
我收到了.fit()方法标题中显示的错误,并且由于我是 ML 新手,因此对文档了解不多。
完整错误:
File "C:/NNC/Main.py", line 14, in <module>
data.target.array([])
File "C:\NNC\venv\lib\site-packages\pandas\core\generic.py", line 5179, in __getattr__
return object.__getattribute__(self, name) …Run Code Online (Sandbox Code Playgroud) 使用此代码无需无头方法.. 网站链接:https ://www.na-kd.com/en/sweaters?sortBy = popularity&count = 108
try:
element = self.driver.find_element_by_xpath('//*[@id="container"]/div/div/div[3]/div/div[4]/div/div[1]/div[2]/div[1]/button')
self.driver.execute_script("arguments[0].click();", element)
except Exception as e:
print('Error in clicking BTN : '+str(e))
Run Code Online (Sandbox Code Playgroud)
因为这个 btn 里面有 div-tag,所以它不能用于无头和虚拟显示。
我也尝试等待:
try:
element=WebDriverWait(self.driver, 20).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="container"]/div/div/div[3]/div/div[4]/div/div[1]/div[2]/div[1]/button')))
self.driver.execute_script("arguments[0].click();", element)
except Exception as e:
print('Error in clicking BTN : '+str(e))
Run Code Online (Sandbox Code Playgroud)
chromedriver --version
ChromeDriver 78.0.3904.70
谷歌浏览器 78.0.3904.108
python selenium headless selenium-chromedriver selenium-webdriver
我试过了pip3 install torch --no-cache-dir,几秒钟后,我得到了这个:
Collecting torch
Downloading https://files.pythonhosted.org/packages/24/19/4804aea17cd136f1705a5e98a00618cb8f6ccc375ad8bfa437408e09d058/torch-1.4.0-cp36-cp36m-manylinux1_x86_64.whl (753.4MB)
100% |????????????????????????????????| 753.4MB 5.7MB/s
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 342, in run
requirement_set.prepare_files(finder)
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File "/usr/lib/python3/dist-packages/pip/download.py", line 821, in unpack_url
hashes=hashes
File "/usr/lib/python3/dist-packages/pip/download.py", line 663, in unpack_http_url
unpack_file(from_path, location, content_type, link)
File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 617, in unpack_file
flatten=not filename.endswith('.whl')
File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", …Run Code Online (Sandbox Code Playgroud) 当我尝试导入使用 pip3 安装的任何模块时,系统只会向我发送大量文本。很抱歉我无法指定更好的内容,但我对 python 和 ubuntu 很陌生。我尝试了命令 pip3 list 然后我得到这个:
/usr/lib/python3/dist-packages/secretstorage/dhcrypto.py:15: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
from cryptography.utils import int_from_bytes
/usr/lib/python3/dist-packages/secretstorage/util.py:19: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
from cryptography.utils import int_from_bytes
Run Code Online (Sandbox Code Playgroud)
之后,我得到了一些软件包及其版本的列表。我记得安装的软件包没有出现在列表中,例如NumPy或random。我正在使用python 3.8和pip 3。
一切都很完美,但我尝试安装 Visual 或 python 模块,之后出现了错误。我想我尝试使用 pip 安装模块,然后使用 conda 安装模块。我不知道该怎么做。
我刚刚使用conda在Win-10上安装了cupy v-6 conda install -c anaconda cupy,安装进行得很顺利,我的cuda版本是10.1,Python 3.7.4,
当我运行以下代码时,出现错误:AttributeError: module 'cupy' has no attribute 'array'
打印目录结果:
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'cp', 'np']
Run Code Online (Sandbox Code Playgroud)
编辑:
完全错误
Traceback (most recent call last):
File "D:\code\cupy.py", line 2, in <module>
import cupy as cp
File "D:\code\cupy.py", line 4, in <module>
x_gpu = cp.array([1, 2, 3])
AttributeError: module 'cupy' has no attribute 'array'`
The code:
Run Code Online (Sandbox Code Playgroud)
我的代码
import numpy as np
import cupy as cp
x_gpu = cp.array([1, 2, 3])
Run Code Online (Sandbox Code Playgroud) python ×6
android ×2
java ×2
pip ×2
python-3.x ×2
cupy ×1
dart ×1
emulation ×1
flutter ×1
headless ×1
import ×1
leakcanary ×1
macos ×1
module ×1
pytorch ×1
scikit-learn ×1
selenium ×1