如何cardview禁用?是否有一些默认的后台资源,支持这个?设计指南?
目前我正在删除高程并将背景更改为灰色...
是否有默认方式显示a cardview已禁用?
我在某些设备上遇到上述错误(很少见,直到现在才2次):
android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 3850)
at android.database.sqlite.SQLiteConnection.nativeExecuteForString(Native Method)
at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:679)
at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:361)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:236)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:200)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
at ***.a(***.java:115)
Run Code Online (Sandbox Code Playgroud)
我的代码中的第115行如下:
// here the exception occurs
SQLiteDatabase db = SQLiteDatabase.openDatabase(pathApp, null, SQLiteDatabase.OPEN_READONLY);
// ...
db.close();
Run Code Online (Sandbox Code Playgroud)
故事
我的工作如下:
就这样.这适用于数千种设备.我的应用程序肯定只能在现场访问数据库,我完全确定
题
有谁知道什么可能导致这个问题?
也许有趣的事实
我使用以下方法来获取屏幕大小:
public static Point getScreenSize(Context context)
{
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
int w = wm.getDefaultDisplay().getWidth();
int h = wm.getDefaultDisplay().getHeight();
return new Point(w, h);
}
Run Code Online (Sandbox Code Playgroud)
在我的三星Galaxy s6上,此方法返回1080x1920 ...虽然我的设备的分辨率为1440x2560.
为什么?有没有更好的方法来获得适用于较新手机的屏幕分辨率?
编辑
我在服务中需要这种方法!我没有帮助的视图/活动,只有应用程序上下文!我需要REAL像素
我正在从 Android 加载所有应用程序,然后将它们显示在我的启动器中(图标+名称)。代码如下:
public class PhoneAppItem
{
String mPackageName = null;
String mActivityName = null;
String mName = null;
ActivityInfo mActivityInfo = null;
public PhoneAppItem(String packageName, String activityName)
{
mPackageName = packageName;
mActivityName = activityName;
}
public void loadInfo()
{
PackageManager pm = MainApp.get().getPackageManager();
try
{
// following line throws the exception!
mActivityInfo = pm.getActivityInfo(new ComponentName(mPackageName, mActivityName), 0);
// some other code...
}
catch (PackageManager.NameNotFoundException e)
{
L.e(e);
mName = mPackageName;
}
catch (NullPointerException e)
{
L.e(e);
mName = mPackageName; …Run Code Online (Sandbox Code Playgroud) 我有一个非常大的项目,为了提高编译速度,我开始测试预编译的头文件。
我现在已经设置了一切:
StdAfx.h仅创建它)StdAfx.hStdAfx.h通过 VS 的强制包含自动包含在我的所有文件中现在出现的问题如下:
我是否需要删除已添加到文件中的所有项目文件的所有包含内容,StdAfx.h还是没有必要?编译器会自动跳过任何包含,因为他知道它是/文件的一部分StdAfx.h还是我应该手动从每个.h/.cpp文件中删除它们?
在 C++ 中是否有类似以下内容:
https://kotlinlang.org/docs/reference/null-safety.html#safe-calls
我想缩短如下调用:
int x = 0;
IPtr pClass(...);
if (pClass)
{
pClass->...
pClass->...
x = pClass->function();
}
Run Code Online (Sandbox Code Playgroud)
我可以使用任何宏/语言技巧来使它看起来像以下伪代码?
IPtr pClass(...);
pClass?->... // only call function if pClass != nil
pClass?->... // only call function if pClass != nil
int x = pClass?->function() | 0; // only call function if pClass != nil, otherwise assign 0 to x
Run Code Online (Sandbox Code Playgroud)
编辑 - 用例
我为其他软件开发了一些插件,而我自己的其他插件可能可用或不可用。
最简单的例子是一个日志插件,我希望在我的代码中有很多日志调用,并且只想记录一些东西,如果日志模块被加载并且可用。我从我的插件所用的软件中获得了一个指向单例记录器模块的指针。我的代码会被日志行污染,如下所示:
if (logger)
{
logger->log(...);
}
Run Code Online (Sandbox Code Playgroud)
并且使它成为一个单内衬而没有 if that is null safe 会更漂亮和紧凑......
这在过去有效,但在我的android pie设备上不再起作用(直到最近的pie更新才起作用):
fun uninstallApp(packageName: String) {
val packageURI = Uri.parse("package:$packageName")
val intent = Intent(Intent.ACTION_DELETE, packageURI)
intent .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent )
}
Run Code Online (Sandbox Code Playgroud)
我找不到任何文档表明此意图不再起作用。
有谁知道是否有其他方法可以在Android Pie上打开卸载对话框?
我正在从系统中检索所有可能的快捷方式,如下所示:
val pm = context.getPackageManager()
val shortcutsIntent = Intent(Intent.ACTION_CREATE_SHORTCUT)
val ril = pm.queryIntentActivities(shortcutsIntent, 0)
// I progress this data and show my users a custom dialog with apps
// and possible shortcuts and then will start the shortcut setup with ACTION_CREATE_SHORTCUT intent
Run Code Online (Sandbox Code Playgroud)
这里的问题是,在android O或更高版本上,例如还会返回新的静态快捷方式-就我所知,应用程序必须是默认启动器。我可以以某种方式过滤掉它们吗?
我有一个像应用程序这样的边栏,并且由于缺少权限而只能支持普通的快捷方式,而不能支持较新的静态/动态快捷方式...
例
Gmail例如提供了标签的快捷方式-我在上面看到了这个可能的快捷方式。但是,如果我开始设置如下所示的快捷方式
val i = Intent(Intent.ACTION_CREATE_SHORTCUT)
i.addCategory(Intent.CATEGORY_DEFAULT)
i.component = ComponentName(packageName, activityName)
startActivityForResult(i, RequestCodes.SHORTCUT_CREATE_REQUEST_CODE)
Run Code Online (Sandbox Code Playgroud)
并等待结果,我不回来的Intent有Intent.EXTRA_SHORTCUT_INTENT(像所有其他人Intent.EXTRA_SHORTCUT_ICON,...)在里面,但一个与LauncherApps.EXTRA_PIN_ITEM_REQUEST它。但这为时已晚,我想从上面的列表中删除此快捷方式,因为我知道我的应用由于缺少权限而无法启动此类快捷方式...
在检查了谷歌问题和很多其他问题之后,我找到了我在底部添加的解决方案。
我所关心的事情如下:
onCreateAND 中onStartCommand,我确保将服务移至前台(如果它尚未位于前台)onStartCommand处理程序的额外命令来执行此操作,以确保服务在启动时不会停止(最终在它完成进入前台之前)context.stopService(...)),我总是通过正在运行的服务本身的命令来停止服务 - 所以我确保它只能在它在前台运行时停止,而不是在启动期间停止我个人使用该服务进行覆盖,因此我不在类中处理活页夹,因为我不使用它们。
我得到的日志
2019-07-29 21:41:27,146 [[BaseOverlayService:62 onCreate]]: onCreate
2019-07-29 21:41:27,146 [[BaseOverlayService:142 b]]: BEFORE moveToForeground (called by onCreate)
2019-07-29 21:41:27,152 [[BaseOverlayService:159 b]]: AFTER moveToForeground (called by onCreate) - moved to foreground: true
2019-07-29 21:41:27,176 [[BaseOverlayService:79 onStartCommand]]: onStartCommand: isForeground: true | action: null | isStopping: false
2019-07-29 21:41:27,945 [[BaseOverlayService:142 b]]: BEFORE moveToForeground (called by updateNotification [OverlayService [onInitFinished]])
2019-07-29 21:41:27,947 [[BaseOverlayService:159 b]]: AFTER moveToForeground (called …Run Code Online (Sandbox Code Playgroud) 在 RxJava 中,有一个valve运算符允许暂停(和缓冲)流并再次恢复流(并且在恢复后立即发出缓冲的值)。它是 rx java 扩展的一部分(https://github.com/akarnokd/RxJavaExtensions/blob/3.x/src/main/java/hu/akarnokd/rxjava3/operators/FlowableValve.java)。
kotlin 流程有类似的东西吗?
我的用例是我想观察活动内的流程并且永远不会丢失事件(就像我会用LiveDataeg 做的那样,如果活动暂停,它将停止观察数据)。因此,当活动暂停时,我希望流程缓冲观察到的值,直到活动恢复为止,并在活动恢复后立即将它们全部发出。
因此,当活动被创建时(直到它被销毁),我想观察流程,但我只想在活动处于活动状态时发出值,并在活动不活动(但仍然创建)时缓冲值,直到它再次活动。
有什么办法可以解决这个问题或者有人写过什么东西来解决这个问题吗?
android ×7
c++ ×2
foreground ×1
function ×1
kotlin ×1
kotlin-flow ×1
resolution ×1
service ×1
shortcut ×1
sqlite ×1