flutter-moum / flutter_hardware_buttons Goto Github PK
View Code? Open in Web Editor NEWFlutter plugin for detecting all hardware buttons
License: MIT License
Flutter plugin for detecting all hardware buttons
License: MIT License
would it be possible to emit an single event when volume button goes from not pressed to pressed (raising edge) and the way round (when a button goes from pressed to not pressed)? I am developing a stopwatch timer and it is important to catch the raising and fallinge edges.
Can't get it to work at all ..
It asks for permission to display over other apps.
Also, volume buttons no longer change volume while app is running
Hi,
Do you have the opportunity to upgrade the version of kotlin ?
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher.
The following dependencies do not satisfy the required version:
project ':hardware_buttons' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71
I’m trying to detect whether a user of my app is attempting to hard reboot their phone (iOS) in attempt to cheat the score in the app.
Once a long press is detected I will like to run some code. Is this possible?
지금 안드로이드에서 딱히 방법이 없어서 꼼수로 보이지 않는 윈도우 뷰를 새로 만들어서 거기서 KeyEvent를 처리하도록 했는데요, 그러다보니 앱에서 키보드가 안나오는 버그가 있습니다 ㅋㅋㅋ
이 사람도 문제 자체는 다르지만 비슷하게 윈도우 뷰를 쓰는 방식을 한게 있는데, 아래 댓글로 "Brilliant! Thanks. One problem here is that soft keyboard cant be opened :(" 라고 하네요 ㅎ.ㅎ....
윈도우 뷰를 띄우지말고 다른 방식을 찾아봐야하나 해서 삽질을 꽤 많이 해봤는데 지금까지 알기로는 그냥 윈도우 뷰를 계속 쓰는게 나은거같고.
일단 삽질 결과 해결 방법은 찾은거같아서 풀리퀘 올릴게요.
하.. 근데 애초에 보이지않는 윈도우 뷰를 만든다는거 자체가 뭔가 불안하네요 ㅋㅋㅋㅋㅋ
Hi,
Is it possible to otherwise detect volume button events on Android so you do not have to ask for permissions?
[https://github.com/manueldeveloper/cordova-plugin-volume-buttons/blob/master/src/android/VolumeButtonsListener.java](Cf plugin ionic )
Is there anyway to make this package compatible with swift 4.0?
I have very little knowledge of swift and struggling to find a way to update/change the functions to be compatible with 4.0
홈버튼을 감지할 때 사용하는 코드는 UIApplicationDidEnterBackground이다.
이는 앱 실행이 백그라운드로 간 후에 작동하는 코드인데,
락 버튼을 눌러 잠금상태에 들어갈때에도 감지한다.
이 상항에서
두 가지 방법이 있는데,,,,
1번이 있으면 좋겠지만.. 아직은 찾지 못했다!
2번 방향으로 해도 될까.....(?)(?)~~?
Realice las pruebas en 3 dispositivos físicos Samsung y Huawei(P9 Lite y Y9), solo funciono con el dispositivo de la marca Samsung, con los otros dispositivos no detecta el evento del Botón Bloqueo/Encendido.
안드로이드는 일단 락버튼을 감지할 수 있는걸로 아는데, 갓진님이 알아본 바로 iOS에서는 막혀있다고 한다.
안드로이드도 조사는 해 봐야 한다. 락버튼을 오래 누르면 락이 되는게아니고 전원 끄기/다시 시작 이런 메뉴가 뜨는데 이런걸 분기태울수 있는지.. 분기를 태우긴 해야하는지를 고민해봐야 한다.
iOS는 어짜피 락버튼을 할 수 없기 때문에 그 시간에 silent 버튼 감지를 구현할 수 있는지 알아보고, 가능하다면 이걸 진행!
I have been trying to get my app to detect the # of volume down clicks on iOS. However, I can't seem to get it to detect any volume clicks in general. One exception is, I can get the home button to be detected but not anything else.
Hi,
Is it possible to intercept events generated by hardware buttons completely? For example if the app is active and volume up/down button is pressed, is it possible to intercept that event in the app handle it in the app specific way and most importantly prevent it from being acted upon further by the system so that the default behaviour that actually turns the volume up/down and displays the system dialog/popup showing the volume going up/down would not happen?
Thanks in advance for your reply!
K.
After adding this to my code it does not work anymore.
`import 'package:hardware_buttons/hardware_buttons.dart';
StreamSubscription _volumeButtonSubscription; //Volume button
@OverRide
void initState() {
super.initState();
_volumeButtonSubscription =
volumeButtonEvents.listen((VolumeButtonEvent event) {
if (event == VolumeButtonEvent.VOLUME_UP) {
minViewer += 5;
maxViewer += 5;
} else if (event == VolumeButtonEvent.VOLUME_DOWN && minViewer >= 6) {
minViewer -= 5;
maxViewer -= 5;
}
});
}
@OverRide
void dispose() {
super.dispose();
_volumeButtonSubscription?.cancel();
}
`
Full Error:
`Launching lib\main.dart on M2007J20CG in debug mode...
Running Gradle task 'assembleDebug'...
e: D:\Development\flutter.pub-cache\hosted\pub.dartlang.org\hardware_buttons-1.0.0\android\src\main\kotlin\flutter\moum\hardware_buttons\EmptyActivityLifecycleCallbacks.kt: (8, 6): Class 'EmptyActivityLifecycleCallbacks' is not abstract and does not implement abstract member public abstract fun onActivityPaused(@nonnull p0: Activity): Unit defined in android.app.Application.ActivityLifecycleCallbacks
e: D:\Development\flutter.pub-cache\hosted\pub.dartlang.org\hardware_buttons-1.0.0\android\src\main\kotlin\flutter\moum\hardware_buttons\EmptyActivityLifecycleCallbacks.kt: (9, 5): 'onActivityPaused' overrides nothing
e: D:\Development\flutter.pub-cache\hosted\pub.dartlang.org\hardware_buttons-1.0.0\android\src\main\kotlin\flutter\moum\hardware_buttons\EmptyActivityLifecycleCallbacks.kt: (11, 5): 'onActivityResumed' overrides nothing
e: D:\Development\flutter.pub-cache\hosted\pub.dartlang.org\hardware_buttons-1.0.0\android\src\main\kotlin\flutter\moum\hardware_buttons\EmptyActivityLifecycleCallbacks.kt: (13, 5): 'onActivityStarted' overrides nothing
e: D:\Development\flutter.pub-cache\hosted\pub.dartlang.org\hardware_buttons-1.0.0\android\src\main\kotlin\flutter\moum\hardware_buttons\EmptyActivityLifecycleCallbacks.kt: (15, 5): 'onActivityDestroyed' overrides nothing
e: D:\Development\flutter.pub-cache\hosted\pub.dartlang.org\hardware_buttons-1.0.0\android\src\main\kotlin\flutter\moum\hardware_buttons\EmptyActivityLifecycleCallbacks.kt: (17, 5): 'onActivitySaveInstanceState' overrides nothing
e: D:\Development\flutter.pub-cache\hosted\pub.dartlang.org\hardware_buttons-1.0.0\android\src\main\kotlin\flutter\moum\hardware_buttons\EmptyActivityLifecycleCallbacks.kt: (19, 5): 'onActivityStopped' overrides nothing
e: D:\Development\flutter.pub-cache\hosted\pub.dartlang.org\hardware_buttons-1.0.0\android\src\main\kotlin\flutter\moum\hardware_buttons\EmptyActivityLifecycleCallbacks.kt: (21, 5): 'onActivityCreated' overrides nothing
e: D:\Development\flutter.pub-cache\hosted\pub.dartlang.org\hardware_buttons-1.0.0\android\src\main\kotlin\flutter\moum\hardware_buttons\HardwareButtonsWatcherManager.kt: (74, 42): Object is not abstract and does not implement abstract base class member public abstract fun onActivityStarted(@nonnull p0: Activity): Unit defined in flutter.moum.hardware_buttons.EmptyActivityLifecycleCallbacks
FAILURE: Build failed with an exception.
Compilation error. See log for more details
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 11s
Exception: Gradle task assembleDebug failed with exit code 1
`
This is one of the down-sides to flutters plugin system.
Each plugin we depend on becomes a new liability. We now need all those plugin developers to keep up with the breaking changes pushed by google.
음.. 하다보니까 안드로이드에서 작업할 때 EventChannel.StreamHandler 인터페이스를 override 해서 onListen 함수에서 버튼 감지 이벤트 듣기 시작하고 onCancel 함수에서 듣던거 캔슬하는데, 앱이 종료되어도 onCancel 함수가 안불리는 버그가 있나봐여.
그래서 앱을 꺼도 버튼 감지 이벤트 캔슬이 안되어서 플러터 앱은 종료되었는데 자꾸 메시지 보내려고하니까 "W/FlutterJNI: Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: flutter.moum.hardware_buttons.volume. Response ID: 0" 요론 메시지가 계속 올라가네요.
이런 버그가 있어서 battery 라는 플러그인에서도 이거 회피하려고하는 풀리퀘를 진행중인듯.
위 풀리퀘보고 좀 따라해서 회피해야할듯. 결국은 플러터팀에서 onCancel 함수가 제대로 불리도록 수정해 줘야겠지만!
iOS는 이런 버그가 없을수도 있지만 혹여나 앱을 종료했을 때 위와 같은 에러 메시지 안뜨나 확인해보심 좋을듯여~
나중을 위해 적어둠!
Hi,
When i run my project, I get the following errors
/....../flutter/.pub-cache/hosted/pub.dartlang.org/hardware_buttons-0.2.1/ios/Classes/VolumeButtenStreamHandler.swift:43:61: error: 'UIApplicationDidBecomeActive' has been renamed to 'UIApplication.didBecomeActiveNotification'
notificationCenter.removeObserver(Notification.Name.UIApplicationDidBecomeActive)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
UIApplication.didBecomeActiveNotification
UIKit.NSNotification.Name:11:23: note: 'UIApplicationDidBecomeActive' was obsoleted in Swift 4.2
public static let UIApplicationDidBecomeActive: NSNotification.Name
^
/....../flutter/.pub-cache/hosted/pub.dartlang.org/hardware_buttons-0.2.1/ios/Classes/VolumeButtenStreamHandler.swift:49:42: error: 'AVAudioSessionCategoryAmbient' has been renamed to 'AVAudioSession.Category.ambient'
try audioSession.setCategory(AVAudioSessionCategoryAmbient)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AVAudioSession.Category.ambient
AVFoundation.AVAudioSessionCategoryAmbient:3:12: note: 'AVAudioSessionCategoryAmbient' was obsoleted in Swift 3
public let AVAudioSessionCategoryAmbient: AVAudioSession.Category
Do you have an idea ?
Thanks
Hai,,
I just success use this plugin, with functionality in android and iOS. But when i upload my iOS app to Appstore, this app was rejected. This message from Apple reviewer.
=========
Guideline 2.5.1 - Performance - Software Requirements
Your app uses or references the following non-public APIs:
com.apple.springboard.lockcomplete
The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change.
Continuing to use or conceal non-public APIs in future submissions of this app may result in the termination of your Apple Developer account, as well as removal of all associated apps from the App Store.
Next Steps
If you are using third-party libraries, please update to the most recent version of those libraries. If you do not have access to the libraries' source, you may be able to search the compiled binary using the "strings" or "otool" command line tools. The "strings" tool can output a list of the methods that the library calls and "otool -ov" will output the Objective-C class structures and their defined methods. These tools can help you narrow down where the problematic code resides. You could also use the "nm" tool to verify if any third-party libraries are calling these APIs.
Resources
If there are no alternatives for providing the functionality your app requires, you can use Feedback Assistant to submit an enhancement request.
========
How can i solve this? can i change this options for calling package?
Thanks
Hi,
On iPhone 6s plus, there is no event volume up and volume down.
hardware_buttons: ^0.2.2
void initState() { super.initState(); _volumeButtonSubscription = volumeButtonEvents.listen((VolumeButtonEvent event) { print(event); setState(() { hasClickVolumeDown = VolumeButtonEvent.VOLUME_DOWN == event; hasClickVolumeDown = VolumeButtonEvent.VOLUME_UP == event; }); }); }
Hi,
Do you integrate the detection of mute and bixby buttons?
Thanks
리젝사유가 되든 안되든
일단 구현하는 방향으로!
유저의 선택으로 남기기~~
Hi, this isn't really an issue but I was wondering if there was a way to listen for multiple button presses?
e.g. Home + Lock button ..
When I try to do this (to take a screenshot on iOS) their is no recognition of either button being pressed.
Many thanks
I think it should be better to detect lock screen than lock button. (because of appstore reject issue)
Please review this method.
func applicationProtectedDataDidBecomeAvailable(_ application: UIApplication) {
print("applicationProtectedDataDidBecomeAvailable")
}
func applicationProtectedDataWillBecomeUnavailable(_ application: UIApplication) {
print("applicationProtectedDataWillBecomeUnavailable")
}
기본 볼륨버튼 동작외 다른 동작 구현이 가능할까!?
ex) e-Book 볼륨버튼으로 페이지 넘기기
iOS 안될 것 같지만,, 알아보겠다!
Lock button plugin can't detect immediately.
It's detecting when the app returns from background to foreground.
Users who use the plugin will expect Immediate detection. (like a home button action)
Do you plan to provide this feature in the future?
If you don't support it, I think you should write the README about this timing issue.
Thanks.
Hi~ Thank you for developing this plugin!
But I can't use your plugin because it is not migrated to AndroidX.
I got this error.
> Configure project :hardware_buttons
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
*********************************************************
WARNING: This version of device_info will break your Android build if it or its dependencies aren't compatible with AndroidX.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
Command: /Users/yusong-i/development/PassionIndicator/android/gradlew app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
Hello, Is it possible to access hardware buttons on headless? I'm getting null error on activity, found this issue on another repository which I believe is related:
I am building an app that would act as a remote for presentations. I would like to use the volume buttons to trigger some sort of event. Can I capture hardware button clicks in flutter?
add detect recent app
I am trying to detect volume button but when i press volume button in a android v10 device, current screen of the app get freezed. After freezing, i can not go back, not able to tab any button on the scrren.
The app is running well in android 9 and lower versions but it is stucked in version 10. Please help me....i badly need this plugin.
iOS는 99.9%로 안되겠지만 안드는 가능해서, 수요도 어느정도 있을듯.
e.g. ebook 앱에서 볼륨 버튼으로 페이지 넘기기.
When canceling the StreamSubscription the app crashes either instantly or after a few seconds. The apple crash log points to audioSession.removeObserver as the last "Last Exception Backtrace (0)".
@giantsol Can you look at this?A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.