我希望能够根据需要从我的Android应用程序获得有效通知.(实际上我只需要知道是否有)我一直在寻找这种行为,似乎,我只有两个选项:NotificationManager.getActiveNotifications()这正是我需要的,但只能从SDK 23或使用NotificationService但我可以使用真的不喜欢这个解决方案,因为我必须向我的应用程序提供阅读所有通知的权限,这绝对是一种过度杀伤力.
有没有人知道任何行为类似NotificationManager.getActiveNotifications()但不需要SDK> = 23的解决方案?
提前致谢!
简短说明:libclang用于自动完成代码不适用于与 Sublime Text 3 捆绑在一起的 python。
详细信息:Github上的 repo 中有一个可验证的小示例
本质上,有一个脚本使用稍微改变的cindex.py(兼容 python 3 和 clang 3.8)并从测试源文件构建翻译单元。然后它重新解析它并尝试完成。
该脚本在使用来自 Powershell 的 Python 3.3.5 时按预期工作。
当放入 Sublime Text 3 上的 Packages 文件夹时,它会产生错误。Sublime Text 3 报告的 Python 版本是 3.3.6。错误:
Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 78, in reload_plugin
m = importlib.import_module(modulename)
File "./python3.3/importlib/__init__.py", line 90, in import_module
File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
File …Run Code Online (Sandbox Code Playgroud) 使用此代码(有效的C++ 11):
#include <stdio.h>
#include <typeinfo>
bool my_awesome_func(int param) {
return (param > 1);
}
int main(int argc, char const *argv[]) {
fprintf(stderr, "type of my_awesome_func: %s\n",
typeid(my_awesome_func).name());
if (my_awesome_func) {
fprintf(stderr, "WHAT???\n");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
问题出在if声明中.虽然typeid返回一些看起来像的东西FbiE(我认为是函数类型的gcc语言)我不明白为什么这种类型被隐式转换成bool(只是一个例子,也适用int).
为什么if语句编译和评估为真?
例如,Eigen::Matrix3i我们可以使用以下语法初始化:
Eigen::Matrix3i T;
T << 1, 0, 0,
0, 2, 0,
0, 0, 3;
Run Code Online (Sandbox Code Playgroud)
但是,在样式中使用clang-format(本例中为3.6)时,Google这种不错的初始化变为:
Eigen::Matrix3i T;
T << 1, 0, 0, 0, 2, 0, 0, 0, 3;
Run Code Online (Sandbox Code Playgroud)
有避免这种情况的简便方法吗?有没有办法告诉clang-format你跳过这样的事情?
我之前搜索过堆栈溢出,但没有找到适合我的问题的答案.
我有一个带有协调器布局的Android应用程序,里面有一个嵌套的ViewPager.如果我在View分页器中滚动第一个片段内的RecyclerView,则隐藏工具栏并按预期显示.但是,我在ViewPager中的其他片段没有嵌套滚动,所以我想显示工具栏是否隐藏在ViewPager页面更改上.我想知道我是否可以扩展CoordinatorLayout行为以完成它.
提前致谢!如果需要,我很乐意提供更多细节.
大概的代码是(试图剥离所有不必要的东西): main_activity.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/tab_layout"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
和滚动片段: fragment.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v7.widget.CardView
android:id="@+id/add_word_card"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<RelativeLayout
android:id="@+id/add_word_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/highlight">
<!-- some unrelated stuff -->
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_below="@id/add_word_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:context=".MainActivity"/>
Run Code Online (Sandbox Code Playgroud)
我发现了一些相关的问题:这个或者这个.但是他们主要关注布局问题,而我想了解是否真的有一个很好的解决方案来按需触发工具栏移动.
android android-layout android-fragments android-recyclerview android-coordinatorlayout
经过广泛搜索后,似乎没有人对同样的行为感兴趣.如果我错过了,请指出适当的地方.
问题如下:我在主活动xml中有一个协调器布局.在协调器布局内部有一个视图寻呼机.在我放入视图分页器的三个片段中的两个片段中,有一些循环视图触发了协调器布局中工具栏的隐藏.但是第三个片段没有循环视图.问题在于,当显示工具栏时,第三个片段被绘制得比它应该低,将ui的一部分隐藏在屏幕的下边缘下方.如果隐藏工具栏,则所有内容都会正常显示
所以问题是 - 如何以编程方式隐藏工具栏?例如,当用户滑动到视图寻呼机中的第三个片段时?
如果你认为有更好的方法 - 我也很高兴听到这个.谢谢!
android android-layout android-viewpager android-toolbar android-coordinatorlayout
我为Sublime Text 3开发了一个插件,我的python代码使用c类型绑定来实现clang.有时调用libclang会出现段错误libclang: crash detected during reparsing(我还不明白原因,但这与这个问题无关).这会导致插件主机崩溃.
所以问题是:在python中有什么方法可以从底层c绑定中的失败中恢复?我很乐意在这个遇到崩溃的特定文件中跳过这个动作.
谢谢!
UPD:评论中有一个简短的讨论,有必要进一步阐述缺乏一个适当的小型可重复的例子.这并不是因为我的懒惰,我尽量让它尽可能容易地理解我希望得到帮助的人的问题.但在这种情况下,这真的很难.最初的问题是由libclang segfaulting导致的一些奇怪的情况,我还没有确定.它可能与一个没有c ++ 11支持编译的库有关,另一个在使用c ++ 11支持编译时使用它,但我想强调 - 这与问题无关.这里的问题是python正在调用的东西中有一个段错误,这个段错误导致Sublime Text plugin_host退出.所以这里有一个简单的例子,但不是缺乏尝试.如果你有如何构建一个想法,我也愿意接受建议.抱歉这个问题的质量很差,这是目前我最好的.
python sublimetext libclang sublimetext3 sublime-text-plugin
android ×3
c++ ×2
libclang ×2
python ×2
sublimetext3 ×2
casting ×1
clang-format ×1
eigen ×1
function ×1
python-3.x ×1
sublimetext ×1
types ×1
windows ×1